Proguard obfuscates the names of operations in the manifest library

I have several application projects that use a common library project. I recently tried moving some activity declarations from each AndroidManifest.xml application project to the library manifest and included the merge manifestmerger.enabled=true with manifestmerger.enabled=true in project.properties .

Everything works fine in debug builds, but bad versions (obfuscated by Proguard) fail with an ActivityNotFoundException . This is because Proguard confuses the names of the Acts that are declared in the library manifest, but not those of the application manifest.

I reviewed the combined bin/AndroidManifest.xml file for the application project, and it correctly named the activity names.

Can anyone suggest a workaround?

+6
source share
1 answer

The standard Ant build process calls the aapt tool to create the ProGuard configuration (bin / proguard.txt), which stores the necessary classes (for example, all the actions that it considers to be used). If this does not work for your project structure (possibly an error or an unsupported case), you can save the classes yourself in your proguard-project.txt:

 -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 

If there are still no other classes in the resulting application, you can find a more manual configuration in the ProGuard> Examples> Complete Android Application Guide.

+2
source

All Articles