J'ai cherché partout à ce sujet et je n'ai toujours pas de solution.
Le gradle a minSdkVersion 21 et targetSdkVersion 29
J'ai une erreur uniquement dans l'API 29, puis l'application ne se charge pas et affiche un écran vide. Quand je vois logcat, cela donne une erreur comme celle-ci:
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)
Je pense que cela ressemble à multidex, alors j'ai essayé d'ajouter le code suivant à l'application gradle
fichier multiDexKeepFile ('multidex-config.txt')
fichier multiDexKeepProguard ('multidex-config.pro')
mon multidex-config.txt
com/packagename/appname/androidx.class
mon multidex-config.pro
-keep class androidx.core.app.CoreComponentFactory { *; }
ma classe App étendant MultiDexApplication
public class App extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
mon manifeste
<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">
mon gradle.properties
Android.enableJetifier=true
Android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536m
mon diplôme/application
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'
}
J'ai vraiment besoin d'une solution pour cela. Aidez-moi s'il vous plaît, merci beaucoup!
vous pouvez essayer d'ajouter Java 1.8 compatibilité
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
ajoutez ce code dans votre Android { }
sur app/build.gradle
essayez de ne pas configurer multidex manuellement
Classe d'application
//Remove unused imports
public class App extends Application { //change MultiDexApplication
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
//MultiDex.install(this); //comment this
}
}
gradle: application
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') //comment this
//multiDexKeepProguard file('multidex-config.pro') //comment this
minifyEnabled true
}
release {
proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
//multiDexKeepFile file('multidex-config.txt') //comment this
//multiDexKeepProguard file('multidex-config.pro') //comment this
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' //comment this
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'
}
La mise à jour de "buildToolsVersion" dans "build.gradle" puis une "reconstruction" ont résolu mon problème
Android {... ... ... buildToolsVersion "29.0.3" ... ... ...}