By using Android Studio 3.0 Beta 5, using the default Project (Empty Activity) with Instant Apps on.
To turn on Proguard, I just set all the Build.Gradle (app, base and feature) with
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
When compile the App works fine. However when compile the Instant Apps, it error out.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.elyeproj.myapplication/com.elyeproj.myapplication.feature.MainActivity}: java.lang.ClassNotFoundException: could not find com.elyeproj.myapplication.feature.MainActivity in any atom class loader or parent class loader
It seems like the proguard just doesn't check the dependencies across features. How could this be solved?
Good news! ProGuard is now supported in multi-feature instant app. The fix has been added to the Android Studio 3.2 Canary 14 and newer builds.
To enable code shrinking for the entire app project, you must do so from the base module’s build.gradle
file. That is, you can include custom ProGuard rules in a dynamic feature module, but the minifyEnabled property in dynamic feature module build configurations is ignored.
https://developer.android.com/guide/app-bundle/configure
Sample project can be seen at multi-feature-module project.
Please report AIA Team if you encounter any issues.
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