10

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?

5
  • Reported issue to Google as per issuetracker.google.com/issues/65710224
    – Elye
    Commented Sep 15, 2017 at 7:12
  • @Bedant, Perhaps upvote this question would help raise more attention to it? Thanks.
    – Elye
    Commented Sep 16, 2017 at 1:36
  • Has there been any update on this? Seems like pretty serious limitation given size requirements of Instant Apps. Commented Oct 17, 2017 at 7:45
  • @JohnO'Reilly check the issue listed above issuetracker.google.com/issues/65710224
    – dazza5000
    Commented Oct 18, 2017 at 1:09
  • There will be a sample to show how to proguard your instant app. Generally speaking, you'll have to make your API surface available to other modules by keeping the package and class names as well as accessed public methods.
    – Ben Weiss
    Commented Oct 31, 2017 at 9:27

1 Answer 1

4

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.