Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi Feature Instant Apps can't be proguarded?

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?

like image 705
Elye Avatar asked Sep 15 '17 04:09

Elye


1 Answers

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.

like image 182
Prags Avatar answered Nov 01 '22 09:11

Prags