5
votes

I have enabled proguard in project.properties:

proguard.config=proguard.cfg

My proguard.cfg does not disable obfuscation. But nothing is obfuscated.

I run the project build with

ant release.

Any bells ringing?


-optimizationpasses 5 -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose -optimizations !code/simplification/arithmetic,!field/,!class/merging/

-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.app.backup.BackupAgentHelper -keep public class * extends android.preference.Preference -keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * { native ; }

-keepclasseswithmembers class * { public (android.content.Context, android.util.AttributeSet); }

-keepclasseswithmembers class * { public (android.content.Context, android.util.AttributeSet, int); }

-keepclassmembers class * extends android.app.Activity { public void *(android.view.View); }

-keepclassmembers enum * { public static *[] values(); public static * valueOf(java.lang.String); }

-keep class * implements android.os.Parcelable { public static final android.os.Parcelable$Creator *; }


3
How do you check that nothing is obfuscated? Can you post here your proguard.cfg? Do you see in the ant output that proguard is processing your files? - Victor Ronin
Edited the question with proguard.cfg. I just throw an exception in the source and watch the stacktrace. Kind of stupid, but still works. And I notice that classes that should be obfuscated are not. Also, when building, I see nothing when the build goes through "obfuscating" phase. - Danail

3 Answers

1
votes

You should make sure that your project is configured for your Android SDK:

android update project -p MyProjectDirectory

As of Android SDK r20, the ProGuard configuration file is split into several parts, which are specified in project.properties:

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

The short project-specific configuration is defined in proguard-project.txt (no longer in proguard.cfg, like it was in older versions of the SDK). The SDK documentation may not be entirely up to date in this respect.

When you run ant release, you should see some logging output from ProGuard.

1
votes

@Thanks Danail, Today i just overcome from this problem .Just elaborating

android:debuggable Whether or not the application can be debugged, even when running on a device in user mode — "true" if it can be, and "false" if not. The default value is "false".

For more details you can visit

http://www.vogella.com/tutorials/AndroidDebugging/article.html

1
votes

It was way more trivial than what I thought: we had (in our manifest.xml file) enabled the

android:debuggable="true"

Doh.