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?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
Elye
  • 53,639
  • 54
  • 212
  • 474
  • Reported issue to Google as per https://issuetracker.google.com/issues/65710224 – Elye Sep 15 '17 at 07:12
  • @Bedant, Perhaps upvote this question would help raise more attention to it? Thanks. – Elye Sep 16 '17 at 01:36
  • Has there been any update on this? Seems like pretty serious limitation given size requirements of Instant Apps. – John O'Reilly Oct 17 '17 at 07:45
  • @JohnO'Reilly check the issue listed above https://issuetracker.google.com/issues/65710224 – dazza5000 Oct 18 '17 at 01: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 Oct 31 '17 at 09:27

1 Answers1

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.

Prags
  • 2,457
  • 2
  • 21
  • 38