Android ==> ant and proguard?

2019-07-16 09:46发布

问题:

I am getting the following error while obfuscating my application. How can i define the output jar in my build.xml?

 [java] Shrinking...
 [java] java.io.IOException: The output jar is empty. Did you specify the proper '-keep' options?
 [java]     at proguard.shrink.Shrinker.execute(Shrinker.java:148)
 [java]     at proguard.ProGuard.shrink(ProGuard.java:294)
 [java]     at proguard.ProGuard.execute(ProGuard.java:100)
 [java]     at proguard.ProGuard.main(ProGuard.java:499)

回答1:

The tutorial here has never gone wrong for me.



回答2:

  1. Use Android SDK Tools revision 8 or later
  2. If you do not have build.xml for your project, run command like this in some empty directory android create project --name <Your Project Name> --package <Your Company Name> --target 7 --path . --activity dummy Find build.xml which you can copy to root directory of the project.
  3. In default.properties add reference to proguard settings (proguard.config=proguard.cfg)
  4. Turn off android:debuggable in application manifest.
  5. Run 'ant release' command

You should find directory called ./bin/proguard and ./bin/-release.apk. You can find more details here.