我有一个在Android 5和5.1(API 21和22)中工作的应用程序,但在其他Android版本(6,7和8)中工作正常,我在google play console中得到一个奇怪的错误。我使用multidex
,因为我在应用程序中有很多库,但我不认为它的问题是'任何帮助!
> java.lang.RuntimeException: > at android.app.ActivityThread.installProvider (ActivityThread.java:5558) > at android.app.ActivityThread.installContentProviders (ActivityThread.java:5150) > at android.app.ActivityThread.handleBindApplication (ActivityThread.java:5090) > at android.app.ActivityThread.access$1600 (ActivityThread.java:177) > at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1509) > at android.os.Handler.dispatchMessage (Handler.java:102) > at android.os.Looper.loop (Looper.java:145) > at android.app.ActivityThread.main (ActivityThread.java:5938) > at java.lang.reflect.Method.invoke (Native Method) > at java.lang.reflect.Method.invoke (Method.java:372) > at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1195) Caused by: java.lang.ClassNotFoundException: at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass (ClassLoader.java:511) at java.lang.ClassLoader.loadClass (ClassLoader.java:469) at android.app.ActivityThread.installProvider (ActivityThread.java:5543)
这是我的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "XXXXXXXXX"
minSdkVersion 21
targetSdkVersion 26
versionCode 7
versionName "2.01"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
//for export the the room database scheme
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
externalNativeBuild {
ndkBuild {
path 'src/main/jni/Android.mk'
}
}
configurations {
compile.exclude group: 'org.jetbrains', module: 'annotations'
}
lintOptions {
disable 'MissingTranslation'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:${versions.support}"
implementation "com.android.support.constraint:constraint-layout:${versions.constraint}"
implementation "com.android.support:design:${versions.support}"
implementation "com.android.support:cardview-v7:${versions.support}"
implementation "com.github.bumptech.glide:glide:${versions.glide}"
annotationProcessor "com.github.bumptech.glide:compiler:${versions.glide}"
implementation "com.jakewharton:butterknife:${versions.butterKnife}"
annotationProcessor "com.jakewharton:butterknife-compiler:${versions.butterKnife}"
implementation "com.squareup.retrofit2:retrofit:${versions.retrofit}"
implementation "com.squareup.retrofit2:converter-gson:${versions.retrofit}"
implementation "com.squareup.retrofit2:adapter-rxjava2:${versions.rxjava2_adapter}"
implementation "android.arch.lifecycle:extensions:${versions.arch}"
implementation "android.arch.persistence.room:runtime:${versions.arch}"
implementation "android.arch.persistence.room:rxjava2:${versions.arch}"
annotationProcessor "android.arch.lifecycle:compiler:${versions.arch}"
annotationProcessor "android.arch.persistence.room:compiler:${versions.arch}"
implementation "io.reactivex.rxjava2:rxandroid:${versions.rxAndroid}"
implementation "io.reactivex.rxjava2:rxjava:${versions.rxJava}"
implementation "com.jakewharton.rxbinding2:rxbinding:${versions.rxBinding}"
implementation "com.jakewharton.timber:timber:${versions.timber}"
implementation "com.ahmedabdelmeged:networkito:${versions.networkito}"
implementation "com.google.dagger:dagger:${versions.dagger}"
implementation "com.google.dagger:dagger-android:${versions.dagger}"
implementation "com.google.dagger:dagger-android-support:${versions.dagger}"
annotationProcessor "com.google.dagger:dagger-android-processor:${versions.dagger}"
annotationProcessor "com.google.dagger:dagger-compiler:${versions.dagger}"
implementation "com.squareup.okhttp3:okhttp:${versions.okhttp3}"
implementation "com.squareup.okhttp3:logging-interceptor:${versions.okhttp3}"
implementation "com.github.siyamed:android-shape-imageview:${versions.image_shape}"
implementation "joda-time:joda-time:${versions.joda}"
implementation "org.greenrobot:eventbus:${versions.eventbus}"
implementation "com.google.android:flexbox:${versions.flexbox}"
implementation "com.github.chrisbanes:PhotoView:${versions.photoView}"
implementation "de.hdodenhof:circleimageview:${versions.circleImageView}"
implementation "com.github.JakeWharton:ViewPagerIndicator:${versions.ViewPagerIndicator}"
implementation("io.branch.sdk.android:library:${versions.branch}") {
exclude module: 'answers-shim'
}
implementation "com.google.firebase:firebase-messaging:${versions.firebase}"
implementation "com.google.firebase:firebase-ads:${versions.firebase}"
implementation "com.google.firebase:firebase-appindexing:${versions.firebase}"
implementation "com.pushwoosh:pushwoosh:${versions.pushwoosh}"
implementation "com.pushwoosh:pushwoosh-badge:${versions.pushwoosh}"
implementation "com.twitter.sdk.android:tweet-ui:${versions.twitter}"
implementation("com.crashlytics.sdk.android:crashlytics:${versions.crashlytics}") {
transitive = true
}
implementation("com.crashlytics.sdk.android:answers:${versions.answers}") {
transitive = true
}
implementation "com.vimeo.stag:stag-library:${versions.stag}"
annotationProcessor "com.vimeo.stag:stag-library-compiler:${versions.stag}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation("com.mopub:mopub-sdk:${versions.mopub}") {
transitive = true
exclude module: 'libAvid-mopub' // To exclude AVID
exclude module: 'moat-mobile-app-kit' // To exclude Moat
}
implementation "com.facebook.android:audience-network-sdk:${versions.facebook}"
implementation "com.google.android.gms:play-services-analytics:${versions.play_service}"
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:0)
经过长时间的搜索,我找到了解决问题的方法,但我不明白。但如果有人解释,我会为我工作。我会很好
我将以下内容添加到build.gradle
在android配置
中dexOptions {
preDexLibraries = false
}
在build.gradle
自我
afterEvaluate {
tasks.matching {
it.name.startsWith('dex')
}.each { dx ->
if (dx.additionalParameters == null) {
dx.additionalParameters = ['--multi-dex']
} else {
dx.additionalParameters += '--multi-dex'
}
}
}