FORUMS
Remove All Ads from XDA

[Tutorial] How to remove any Ads on any apk without root

7 posts
Thanks Meter: 10
 
By Nrin, Junior Member on 10th December 2017, 03:39 PM
Post Reply Email Thread
Hello,

Today I want to share with you a method to remove any ads from an apk that should work on any Android version without root permissions.

You will need a minimum level of skills to understand the method and a computer (needed to edit the apk).

Obtain the apk
When you install an application, its apk will be placed in /data/app directory. However, you need a rooted phone to access that directory. Luckily, often there is a pre-installed system application to backup your apps (on Huawei there is Huawei Backup) that can access that folder. Thus, you don't need root permissions. You can use this backup pre-installed app to save your apk on the sd and transfer it on your computer.

Edit the apk and re-install it
I'm assuming that you're on Linux, but the same can be done with Windows or Mac. Continue with the following steps:
  1. An apk is just a zip file, thus extract it in a folder. On Linux:
    Code:
    $ unzip com.example.apk
  2. Now, try to look at the strings, regarding ads, in plain text inside the file classes.dex (you don't need to extract it). For example:
    Code:
    $ strings classes.dex | grep "ads"
  3. Keep note about all the ads urls contained in classes.dex (e.g. googleads.g.doubleclick.net)
  4. Use an hex editor as GHex or Bless to replace these ads urls with invalid urls (I suggest to use the same length). So, for example, you can transform: googleads.g.doubleclick.net into foobarfoo.b.arfoobarfoo.bar.
  5. Save overwriting the original classes.dex and zip all the files into a new apk (e.g. com.example_noads.apk)
  6. Sign the new apk. The process is easier using some tools (look for apk signer on google, there are one click tools).
  7. Transfer the new apk on your phone and install it (the phone should ask if you want to upgrade your app, say yes).

In this way, the application should work as always, but it will try to load the ads from invalid urls. Thus, it should not display any ads.

Note: I've tested this method and it works, however it's possible that some applications are encrypted thus there aren't plain text ads urls.

EDIT: I added a new step where you must sign the new apk. In fact, this is the rule. However, when I wrote this post I didn't talk about that, because in my case I found an application that I succesfully re-installed without re-sign the apk (bug? hash collision? I still don't know).
The Following 5 Users Say Thank You to Nrin For This Useful Post: [ View ] Gift Nrin Ad-Free
12th December 2017, 10:31 AM |#2  
OP Junior Member
Thanks Meter: 10
 
More
Application implementing this method available: Purify

I developed an application to do all this process directly and automatically on your phone!
The application is still unmature, consider it a proof of concept. It will remove only google ads for the moment.
Click here to see the source code on GitHub

If you want to try the compiled apk:


Note: This is the first pre-release, keep in mind that it is just an example of implementation. Some purified applications could crash, for example because they don't handle the wrong urls or for other reasons. However, I tested it on some apps and it seems to work. Unpacking, editing and re-packing the apk can require few minutes. Please read further details on the github page linked above.
The Following 3 Users Say Thank You to Nrin For This Useful Post: [ View ] Gift Nrin Ad-Free
28th February 2019, 02:39 PM |#3  
Junior Member
Thanks Meter: 5
 
More
Hey there, thank you very much, I used Purify on android 8.0 and works great. It didn't sign my apk but I signed it from the pc and it installed and worked correctly without ads. Great!

Edit: Zipsigner isn't on the play store any more but I downloaded and installed the apk from apkpure and it signs it but doesn't do it well because it doesn't let me install it after that no matter what kind of sign type do I use. So I sign it from the pc using "signapk"
11th October 2019, 04:34 PM |#4  
Member
Thanks Meter: 2
 
More
Nice app.....now a days ads from other sources are increasing such as facebook.ads, mobileads, inmobi,etc.....to my knowledge, manifest.xml contains every ad activity, service, receiver etc.....is it possible to add an interface to selectively remove those....so that i can remove any ad from any app.......by the way....thanks for your work👍
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes