Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable proguard crashs when run app (Didn't find class "androidx.core.app.CoreComponentFactory")

I have migrated my app to AndroidX. Everything works normally if I disable proguard. If I enable proguard, the app can build successfully but crashed when I open app.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference at com.app.example.utils.da.a(Unknown Source:15) at com.app.exampler.utils.da.b(Unknown Source:10) at com.app.example.utils.da.a(Unknown Source:9) at com.app.example.base.MyApplication.onCreate(Unknown Source:2) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1162) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6636) at android.app.ActivityThread.access$2000(ActivityThread.java:268)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1995)  at android.os.Handler.dispatchMessage(Handler.java:109)  at android.os.Looper.loop(Looper.java:207)  at android.app.ActivityThread.main(ActivityThread.java:7539)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)  2019-07-25 07:14:46.903 1437-1437/? E/LoadedApk: Unable to instantiate appComponentFactory java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[]

I tried some solution below but they didn't help.

proguard-rules.pro

-keep class androidx.core.app.CoreComponentFactory { *; }

manifest.xml

tools:replace="android:appComponentFactory"
android:appComponentFactory="whatevestring"

Anyone got the same issue like me? And how you resolve it? Thank you.

like image 931
CauCuKien Avatar asked Jul 25 '19 00:07

CauCuKien


1 Answers

I got the same issue after enabling proguard. In my case the issue got resolved by cleaning the project. Try to run the app after cleaning.

Android Studio -> Build -> Clean Project

No need to add additional proguard rule or anything additional in manifest file.

Hope it helps!!

like image 103
Mayank jain Avatar answered Oct 17 '22 18:10

Mayank jain