尝试在Lollipop中运行我的应用时出现问题,日志如下:
11-08 15:12:35.816 987-987/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.rocketjourney, PID: 987
java.lang.NoClassDefFoundError: Failed resolution of: Lio/fabric/sdk/android/services/common/FirebaseInfo;
at com.crashlytics.android.CrashlyticsInitProvider.onCreate(CrashlyticsInitProvider.java:22)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1696)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1671)
at android.app.ActivityThread.installProvider(ActivityThread.java:4999)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4594)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4534)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.ClassNotFoundException: Didn't find class "io.fabric.sdk.android.services.common.FirebaseInfo" on path: DexPathList[[zip file "/data/app/com.rocketjourney-2/base.apk"],nativeLibraryDirectories=[/data/app/com.rocketjourney-2/lib/x86, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
我的傻瓜:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.21.6'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.rocketjourney"
minSdkVersion 21
targetSdkVersion 24
versionCode 67
versionName "4.4"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "com.rocketjourney.helpers.CustomTestRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
jumboMode = true
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
exclude group: 'com.android.support', module: 'support-annotations'
}
...
我在发布活动中有这个:
@Override
public void onCreate(Bundle savedInstanceState) {
MultiDex.install(this);
super.onCreate(savedInstanceState);
当我试图解决这个问题时,出现了multiDex的问题,所以我不知道为什么出现这个问题的主要原因是因为我尝试了很多解决方案,但我没有运气。任何帮助表示赞赏。
答案 0 :(得分:4)
在Android Studio终端中输入rm -rf .gradle
,然后重试。这为我解决了!
答案 1 :(得分:2)
确保您的build.gradle
包含multiDexEnabled: true
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
android {
defaultConfig {
....
multiDexEnabled true
}
}
答案 2 :(得分:0)
尝试在Android Studio上停用即时游戏。
答案 3 :(得分:0)
我正在使用Android Studio 3.4,gradle插件版本3.4.0和发行版5.1.1
面对上述问题。
我发现禁用R8发行版正在运行时表示multidex在运行。
要禁用R8,请将其放在gradle.properties文件的下面。
# Disables R8 for Android Library modules only.
android.enableR8.libraries = false
# Disables R8 for all modules.
android.enableR8 = false
答案 4 :(得分:0)
我最近遇到了同样的问题;将Android Studio更新到最新的(3.5)版本,以及Gradle,Firebase和Fabric都为我解决了这个问题。