Proguard does not work when exporting with the Eclipse ADT R19 plugin

When I export my application through Export > Export Android Application or through Android Tools > Export Signed Application Package , I just can't get Proguard to work.

All I know about how to enable Proguard is to uncomment the line

 proguard.config=${sdk.dir}\tools\proguard\proguard-android.txt:proguard-project.txt 

in project.properties .

And I tried to put my configuration file there. Will not work.

The classes.dex file in the exported package contains the class name of private methods, such as onConfirmButtonClicked . Thus, over 99% of the chances that Proguard did not do its job.

After that, I put some random characters in the proguard-project.txt file, but I did not get any errors. The detailed output of the assembly did not refer to Proguard at all.

I wonder what is wrong there.

+4
source share
1 answer

Proguard does its job when you export a project to an .apk file, and you must put the desired configuration in a file (.cfg) and specify that file in project.properties

 proguard.config=${dir}\YOURCONFIGFILE.cfg 

and in this configuration file you have to tell proguard to save all the key elements of your project. For instance:

 -injars bin/classes -injars libs -outjars bin/classes-processed.jar -libraryjars /usr/local/java/android-sdk/platforms/android-9/android.jar -dontpreverify -repackageclasses '' -allowaccessmodification -optimizations !code/simplification/arithmetic -keepattributes *Annotation* -keep public class * extends android.app.Activity -keep public class * extends android.app.Application -keep public class * extends android.app.Service -keep public class * extends android.content.BroadcastReceiver -keep public class * extends android.content.ContentProvider -keep public class * extends android.view.View { public <init>(android.content.Context); public <init>(android.content.Context, android.util.AttributeSet); public <init>(android.content.Context, android.util.AttributeSet, int); public void set*(...); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet); } -keepclasseswithmembers class * { public <init>(android.content.Context, android.util.AttributeSet, int); } -keepclassmembers class * extends android.content.Context { public void *(android.view.View); public void *(android.view.MenuItem); } -keepclassmembers class * implements android.os.Parcelable { static ** CREATOR; } -keepclassmembers class **.R$* { public static <fields>; } -keepclassmembers class * { @android.webkit.JavascriptInterface <methods>; } 

Hope this helps!

0
source

Source: https://habr.com/ru/post/1416586/


All Articles