Search code examples
javaandroidandroid-studioproguardobfuscation

Android Studio Proguard Base location


I'm using Zelix Klass Master to obfuscate my android apps. Been using It for about 1 year. I decided to upgrade my android studio since I was still running version 3.0.1. After updating android studio I can no longer obfuscate my apk with Zelix, It's using Proguard to obfuscate my android application the way Zelix works via proguard is that I need to replace the proguard jar inside the directory

<Android Studio>\gradle\m2repository\net\sf\proguard\proguard-base

I have replaced all the proguard jars in the directory and even delated the proguard parent file inside sf and it still uses proguard to obfuscate my android apk my guess is it no longer uses proguard from <Android Studio>\gradle\m2repository\net\sf\proguard because I deleted that directory and android studio still builds using proguard.

So the question is where is the new proguard lib? and how do I get it to use proguard from that directory (proguard-base) instead? for information about how to setup Zelix you can read it here:

Edit: After Svet's answer I tried doing what he suggested and it's throwing this error now..

Unable to find method 'proguard.KeepClassSpecification.(ZZZZZZZLproguard/ClassSpecification;Lproguard/ClassSpecification;)V'. Possible causes for this unexpected error include:

  • Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.) Re-download dependencies and sync project (requires network)
  • The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem. Stop Gradle build processes (requires restart)
  • Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.


Solution

  • Okay, I have fixed the issue thanks to Svet. I will reward him the bounty for helping me. So He answered and told me I had to change the proguard classPath like the following

    buildscript {  
        repositories {
            flatDir { dirs '/proguard' }
        }
        dependencies {
            classpath ':proguard:'
        }
    }
    

    After that obviously It won't work with the original proguardStub.jar since It's for proguard 5.0 and not 6.0.3 I am taken the code apart and injected code into the old proguardStub.jar to be treated as 6.0.3 and now it finally works! here is the updated proguardStub.jar that I have created here.

    If any of you are wondering how I did it, I just changed the bytecode using ASM so it doesn't cause errors and also changed the old String so it shows 6.0.3 instead of 5.0 :) Of course the String doesn't effect anything rather then just showing what version it is.