Multifunctional applications Instant can not be reprogrammed?

Using Android Studio 3.0 Beta 5, use Project by default with Instant Apps.

To enable Proguard, I just installed all of the Build.Gradle (application, base and function) using

debug {
   minifyEnabled true
   proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}

When compiling the application works fine. However, compiling Instant Apps is a mistake.

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 class atom loader or parent class loader

It seems that proguard just does not check dependencies between functions. How can this be solved?

+6
source share
1 answer

Google AIA Team is working on a fix, thank you for your patience!

A temporary solution to this problem is to configure a massive "-keep" proguard for each function module.

To find out which classes should be saved when setting up a proger, follow these steps:

  • add "-whyareyoukeeping class **" to your application / proguard -rules.pro (installed application module)
  • set installed minifyEnabled applications to true
  • create the installed application, then the Gradle console will contain a list of information about which classes it stores or not.
  • copy this part to some editor so you can edit it
  • , "", " ", , .. -keep class some.package.class {*;} . .
  • , , proguard-rules.pro
  • , base/proguard-rules.pro "-dontobfuscate" ( - )

minifyEnabled true.

5, , , . , , - AWK :

awk '/^[^ ]/ { cls=$1 } /is (kept|a library)/ { print "-keep class " cls " {*;}" }'
0

All Articles