I have searched everywhere about this and still have no solution.
The gradle has minSdkVersion 21 and targetSdkVersion 29
I got error only in API 29, then the app doesn't load and show up blank screen. When i see logcat it gives an error like this :
E/LoadedApk: Unable to instantiate appComponentFactory
java.lang.ClassNotFoundException: Didn't find class "androidx.core.app.CoreComponentFactory" on path: DexPathList[[],nativeLibraryDirectories=[/data/app/com.packagename.appname-BxS7Zs-h0IWwJAVhbjx7aQ==/lib/x86, /data/app/com.packagename.appname-BxS7Zs-h0IWwJAVhbjx7aQ==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.LoadedApk.createAppFactory(LoadedApk.java:256)
at android.app.LoadedApk.updateApplicationInfo(LoadedApk.java:370)
at android.app.ActivityThread.handleDispatchPackageBroadcast(ActivityThread.java:5951)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1941)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at com.android.server.SystemServer.run(SystemServer.java:541)
at com.android.server.SystemServer.main(SystemServer.java:349)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:908)
I think it seems like from multidex, then i have tried adding following code to gradle app
multiDexKeepFile file('multidex-config.txt')
multiDexKeepProguard file('multidex-config.pro')
my multidex-config.txt
com/packagename/appname/androidx.class
my multidex-config.pro
-keep class androidx.core.app.CoreComponentFactory { *; }
my App class extending MultiDexApplication
public class App extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
my Manifest
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_logo"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_logo"
android:supportsRtl="true"
android:theme="@style/main"
android:usesCleartextTraffic="true"
tools:ignore="GoogleAppIndexingWarning">
my gradle.properties
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
my gradle/app
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.packagename.appname"
minSdkVersion 21
targetSdkVersion 29
versionCode 7
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
multiDexKeepFile file('multidex-config.txt')
multiDexKeepProguard file('multidex-config.pro')
minifyEnabled true
}
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
multiDexKeepFile file('multidex-config.txt')
multiDexKeepProguard file('multidex-config.pro')
minifyEnabled true
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.libraries.places:places:2.2.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.android.support:multidex:2.0.1'
implementation 'com.github.vipulasri:timelineview:1.1.0'
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'com.yanzhenjie.zbar:camera:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'com.amitshekhar.android:android-networking:1.0.2'
implementation 'com.google.firebase:firebase-core:17.2.2'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.github.bumptech.glide:glide:4.11.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
implementation 'com.github.kenglxn.QRGen:android:2.5.0'
implementation 'com.facebook.android:facebook-android-sdk:4.36.0'
implementation 'com.jsibbold:zoomage:1.2.0'
implementation 'androidx.arch.core:core-common:2.1.0'
implementation 'androidx.arch.core:core-runtime:2.1.0'
}
I really need a solution for this. Help me please, thank you so much!
The error is pointing to the use of androidx
CoreComponentFactory
class(using AndroidX) but you are using old package com.android.support:multidex
so use androidx
dependency as:
implementation 'androidx.multidex:multidex:2.0.1'
instead of
implementation 'com.android.support:multidex:2.0.1'
and make sure to use androidx
imports in the application class as
import android.content.Context;
import androidx.multidex.MultiDex;
import androidx.multidex.MultiDexApplication;
public class YourApp extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
MultiDex.install(this);
super.attachBaseContext(base);
}
}
Additionally: During the app Load-up, android Q uses the CoreComponentFactory
instance internally whether you are using it in manifest or not, which is causing the issue.
Also, add multiDexEnabled true
as defaultConfig{multiDexEnabled true }
Update: After the RCA, the componentfactory
import issue was resolved with the androidx
lib imports though there was another issue with the facebook sdk dependency in version 4.36.0
which was resolved by downgrading the version to 4.35.0
(or use latest version integration) and also posted here.