Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use custom proguard.jar in Gradle build?

I am trying to run proguard on my app which includes Unity 3D. Currently proguard fails trying to process unity-classes.jar, and the only workaround is to build proguard myself with a patch applied (see this link for the bug report).

So, I have my own custom proguard.jar now, but how can I get the android plugin to use it? With eclipse this was just a matter of replacing proguard.jar in the Android SDK directory, but this doesn't work anymore with Android Studio/Gradle. In fact, I can delete the proguard files from tools/proguard/lib/, and it still runs!

How can I get Android Studio/Gradle to use my custom built proguard.jar?

like image 424
Greg Ennis Avatar asked Sep 30 '22 22:09

Greg Ennis


1 Answers

I solved this by placing the custom proguard.jar in a directory named "proguard" in the root folder (not project root folder) and setup the gradle file like this:

buildscript {
  repositories {
    flatDir { dirs 'proguard' }
    mavenCentral()
  }

  dependencies {
    classpath 'proguard.io:proguard:5.0'
    classpath 'com.android.tools.build:gradle:0.12.+'
  }
}
like image 66
Greg Ennis Avatar answered Oct 06 '22 20:10

Greg Ennis