1

Actually, I was working on one project and to test the implemented feature, I have build the project but unfortunately, i have got the error like: "Unable to instantiate appComponentFactory" .

I didn't change any kind of gradle or manifest related changes. Just restructure gson response model based restructured API and based on that model, I have also modified some model mapping. and for API calling, I am using retrofit.

I have just added Hilt dependency into app level gradle and did some required changes into the project level gradle as per google documentation.

Here, I want to understand the root of this error.

Thank you in advance!

Here is the error response which i am facing!

Unable to instantiate appComponentFactory
java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[],nativeLibraryDirectories=[/data/app/com.<ProjectName>.app-uNyluFOJTyG6uVYYO-7V6w==/lib/arm64, /data/app/com.<ProjectName>.app-uNyluFOJTyG6uVYYO-7V6w==/base.apk!/lib/arm64-v8a, /system/lib64]]
                                                                                                        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
                                                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
                                                                                                        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
                                                                                                        at android.app.LoadedApk.createAppFactory(LoadedApk.java:226)
                                                                                                        at android.app.LoadedApk.updateApplicationInfo(LoadedApk.java:338)
                                                                                                        at android.app.ActivityThread.handleDispatchPackageBroadcast(ActivityThread.java:5388)
                                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1733)
                                                                                                        at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                        at android.os.Looper.loop(Looper.java:193)
                                                                                                        at com.android.server.SystemServer.run(SystemServer.java:454)
                                                                                                        at com.android.server.SystemServer.main(SystemServer.java:294)
                                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:838)

I have tried many things which are mentioned into one stackOverflow Question.

Didn't find class "androidx.core.app.CoreComponentFactory"

Also, refer some other asked Questions related to the same from the StackOverflow as well as from other sources, but not getting any solution!

But, not a single answer worked for me.

  • Would you be able to share a link to sample app project? I will be able to check it out at my end. – hardik9850 Aug 31 '23 at 06:49
  • Hello Hardik, Due to the NDA with client, I can't share the actual project and i don't know that how this error is going to reproduce. So, I can't create saperate sample project for the same! I am sincerely apologize for that. – Alex Denvers Aug 31 '23 at 06:53
  • That's fine Alex. This kind of errors are nightmares for us devs. – hardik9850 Aug 31 '23 at 06:57
  • Yes.. Exactly!! – Alex Denvers Aug 31 '23 at 07:00
  • Does this answer your question? [Didn't find class "androidx.core.app.CoreComponentFactory"](https://stackoverflow.com/questions/57700486/didnt-find-class-androidx-core-app-corecomponentfactory) – rahat Aug 31 '23 at 08:30
  • No.., I have tried all these solutions but no one are working for me. – Alex Denvers Aug 31 '23 at 08:45
  • Interesting thing is like I have faced same error 3rd time but this time those solutions don't work for me! as well as in my prev project, i had fixed this error by using bellow given answer! – Alex Denvers Aug 31 '23 at 08:48

1 Answers1

1

In my past, I had faced same issue and resolved by changing the following things into gradle.

implementation 'com.android.support:multidex:x.x.x'

to

implementation 'androidx.multidex:multidex:x.x.x'

and have enabled multidex enabled into build.gradle file in defaultConfig section like:

multiDexEnabled true
Akk_
  • 11
  • 2
  • Yess! i had also resolved the same error in my past project by using this approach but some how i am not able resolve same error in this project. – Alex Denvers Aug 31 '23 at 07:47
  • The error is same as my previous project, but this time solution is not applicable. So, I think in latest versions of gradle this solution might not be applicable. – Alex Denvers Aug 31 '23 at 07:50
  • honestly, I am not aware of the root cause of this error so i am bit confused in this! – Alex Denvers Aug 31 '23 at 07:51
  • Ohh, Okey.... Let me check further applicable solution. – Akk_ Aug 31 '23 at 07:53