I have several application projects which use a common library project. I recently tried moving some common Activity declarations from each application project's AndroidManifest.xml into the library's manifest, and enabled manifest merging with manifestmerger.enabled=true
in project.properties
.
Everything works fine in a debug build, but release builds (obfuscated by Proguard) fail with an ActivityNotFoundException
. This is because Proguard is obfuscating the names of Activities which are declared in the library manifest, but not those in the application manifest.
I have examined the merged bin/AndroidManifest.xml
file for the application project, and it correctly has the Activity names listed.
Can someone please suggest a workaround?
The standard Ant build process invokes the aapt tool to create a ProGuard configuration (bin/proguard.txt) that preserves the necessary classes (e.g. all activities that it deems used). If that doesn't work for your project structure (maybe a bug or an unsupported case), you can preserve 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 the resulting application is still missing other classes, you can find more manual configuration in the ProGuard manual > Examples > A complete Android application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With