Fixed
Status Update
Comments
ra...@google.com <ra...@google.com> #2
Is shrinking of the app actually causing a problem with the Initializer
discovery and initialization itself ?
What are you seeing?
ka...@droidsonroids.pl <ka...@droidsonroids.pl> #3
Exactly, stacktrace below. From what I can see several Initializers are present in usage.txt so not only this one is shrunk.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: <stripped>, PID: 12714
java.lang.RuntimeException: Unable to get provider androidx.startup.InitializationProvider: androidx.startup.StartupException: java.lang.ClassNotFoundException: <stripped>.reporting.ReportingInitializer
at android.app.ActivityThread.installProvider(ActivityThread.java:7318)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6778)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6628)
at android.app.ActivityThread.access$1700(ActivityThread.java:232)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1966)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: androidx.startup.StartupException: java.lang.ClassNotFoundException: <stripped>.reporting.ReportingInitializer
at androidx.startup.InitializationProvider.onCreate(Unknown Source:6)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2154)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2128)
at android.app.ActivityThread.installProvider(ActivityThread.java:7307)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6778)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6628)
at android.app.ActivityThread.access$1700(ActivityThread.java:232)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1966)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.ClassNotFoundException: <stripped>.reporting.ReportingInitializer
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at androidx.startup.InitializationProvider.onCreate(Unknown Source:4)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2154)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2128)
at android.app.ActivityThread.installProvider(ActivityThread.java:7307)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6778)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6628)
at android.app.ActivityThread.access$1700(ActivityThread.java:232)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1966)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
Caused by: java.lang.ClassNotFoundException: <stripped>.reporting.ReportingInitializer
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:454)
at java.lang.Class.forName(Class.java:379)
at androidx.startup.InitializationProvider.onCreate(Unknown Source:4)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2154)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2128)
at android.app.ActivityThread.installProvider(ActivityThread.java:7307)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6778)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6628)
at android.app.ActivityThread.access$1700(ActivityThread.java:232)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1966)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7710)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
le...@gmail.com <le...@gmail.com> #4
I've got exaclty the same problem. Classes that extend Initializer are shrinked by R8. It seems that the proguard rules are not included in the artifact. The build.gradle file of the library does not have a consumerProguardFiles to include the proguard-rules.pro.
When I copy/paste the rules directly in the proguard-rules.pro file of my own app module, the rules work and the classes are not shrinked.
When I copy/paste the rules directly in the proguard-rules.pro file of my own app module, the rules work and the classes are not shrinked.
ra...@google.com <ra...@google.com> #5
Thanks. I will fix the proguard rules.
#4: The proguard rules should be a part of the AAR. This looks like a problem with the rules itself.
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 9a82f9c2d7de8d9b26832b34f9c2d604f64893cd
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Tue Jun 23 09:31:45 2020
Add proguard rules to the AAR.
Test: Ran tests with the integration test app.
Fixes: b/159595260
Change-Id: I1e7ada99defaad2f5e8e17c32b37b096d8e91539
M startup/startup-runtime/build.gradle
M startup/startup-runtime/proguard-rules.pro
https://android-review.googlesource.com/1347583
Branch: androidx-master-dev
commit 9a82f9c2d7de8d9b26832b34f9c2d604f64893cd
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Tue Jun 23 09:31:45 2020
Add proguard rules to the AAR.
Test: Ran tests with the integration test app.
Fixes:
Change-Id: I1e7ada99defaad2f5e8e17c32b37b096d8e91539
M startup/startup-runtime/build.gradle
M startup/startup-runtime/proguard-rules.pro
sm...@gmail.com <sm...@gmail.com> #7
Absolutely a millionaire winning thousands upon thousands .. always work with this as we know how to ducceed
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 9a82f9c2d7de8d9b26832b34f9c2d604f64893cd
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Tue Jun 23 09:31:45 2020
Add proguard rules to the AAR.
Test: Ran tests with the integration test app.
Fixes: b/159595260
Change-Id: I1e7ada99defaad2f5e8e17c32b37b096d8e91539
M startup/startup-runtime/build.gradle
M startup/startup-runtime/proguard-rules.pro
https://android-review.googlesource.com/1347583
Branch: androidx-master-dev
commit 9a82f9c2d7de8d9b26832b34f9c2d604f64893cd
Author: Rahul Ravikumar <rahulrav@google.com>
Date: Tue Jun 23 09:31:45 2020
Add proguard rules to the AAR.
Test: Ran tests with the integration test app.
Fixes:
Change-Id: I1e7ada99defaad2f5e8e17c32b37b096d8e91539
M startup/startup-runtime/build.gradle
M startup/startup-runtime/proguard-rules.pro
Description
Component used: Startup
Version used: 1.0.0-alpha1
Devices/Android versions reproduced on: Does not matter
This is a follow-up of closed issue #159561780. Indeed the last comment seems to be true - internal class causes lint error while public does not. However, core of the issue still occurs and the same workaround works. Despite that initializers classes are public they are shrunk by R8.
Maybe some optimization is causing that? AGP: 4.2.0-alpha02 proguard full mode enabled proguard-android-optimize.txt used
Using the following Initializer class (located in library module, listed in its manifest, not added as dependency of any other initializer):
If the following proguard/R8 rule is applied then it works: