更新到Fabric Crashlytics后,有时本机会崩溃与java.lang.NoClassDefFoundError

时间:2017-08-31 14:58:01

标签: android noclassdeffounderror crashlytics google-fabric

最后更新Crashlytics with Fabric本机应用程序崩溃了一些时间(使用Android 7.1.1在nexus 6上测试)

我在Google Play控制台中看到的是这个。

java.lang.NoClassDefFoundError: 
  at io.fabric.sdk.android.Kit.<init> (Kit.java:45)
  at com.crashlytics.android.answers.Answers.<init> (Answers.java:20)
  at com.crashlytics.android.Crashlytics.<init> (Crashlytics.java:29)
  at funler.com.funler.FunlerApplication.onCreate (FunlerApplication.java:27)
  at android.app.Instrumentation.callApplicationOnCreate (Instrumentation.java:1007)
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:4344)
  at android.app.ActivityThread.access$1500 (ActivityThread.java:135)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1256)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:136)
  at android.app.ActivityThread.main (ActivityThread.java:5017)
  at java.lang.reflect.Method.invokeNative (Native Method)
  at java.lang.reflect.Method.invoke (Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:779)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:595)
  at dalvik.system.NativeStart.main (Native Method)

当然是funler.com.funler.FunlerApplication.onCreate (FunlerApplication.java:27)

我有

Fabric.with(this, new Crashlytics());

我发现了与MultiDex.install(this)相关的问题,但我的代码中没有。 还看到了与dexOptions相关的内容,不知道该怎么做。

最大的问题是我无法按需要重现它,在设备中尝试它会发生~1次20次。

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

ext {
        versionSdk = 25

        major = 3
        minor = 2
        patch = 5
}

def generateVersionCode(){

        return ext.versionSdk * 1000000 +
                        ext.major * 10000 +
                        ext.minor * 100 +
                        ext.patch;
}

android {

        compileSdkVersion 25
        buildToolsVersion '25.0.3'
        useLibrary 'org.apache.http.legacy'
        defaultConfig {
                applicationId .
                minSdkVersion 16
                targetSdkVersion 25
                versionCode generateVersionCode()
                versionName "${project.ext.major}.${project.ext.minor}.${project.ext.patch}"
                multiDexEnabled true

                .
        }
        productFlavors {
                .
        }
        buildTypes {
                .
        }
        dexOptions {
                jumboMode = true
        }
}


dependencies {
        compile fileTree(include: ['*.jar'], dir: 'libs')
        // You must install or update the Support Repository through the SDK manager to use this dependency.
        compile 'com.android.support:support-core-ui:25.4.0'
        compile 'com.android.support:appcompat-v7:25.4.0'
        compile 'com.android.support:design:25.4.0'
        compile 'com.facebook.android:facebook-android-sdk:4.5.0'
        compile 'com.pnikosis:materialish-progress:1.5'
        compile 'com.nineoldandroids:library:2.4.0'
        compile('com.google.apis:google-api-services-youtube:v3-rev112-1.19.0') {
                exclude(group: 'com.google.code.findbugs', module: 'jsr305')
        }
        compile('com.google.api-client:google-api-client:1.18.0-rc') {
                exclude(module: 'jsr305')
        }
        compile 'io.branch.sdk.android:library:2.+'
        compile 'com.google.android.gms:play-services-gcm:8.1.0'
        compile 'com.mcxiaoke.volley:library:1.0.7'
        compile 'org.xwalk:xwalk_core_library:22.52.561.4'
        compile files('libs/MobileAppTracker-3.9.jar')
        compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
                transitive = true;
        }
        compile 'org.greenrobot:eventbus:3.0.0'
        provided files('amazon-device-messaging-1.0.1.jar')
}

configurations {
        compile.exclude module: 'jsr305'
}

buildscript {
        repositories {
                maven { url 'https://maven.fabric.io/public' }
        }

        dependencies {
                classpath 'io.fabric.tools:gradle:1.+'
        }
}

repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
}

repositories {
        maven {
                url 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
        }
}
repositories {
        maven { url 'http://download.crashlytics.com/maven' }
}

configurations.all {
        resolutionStrategy.eachDependency { details ->
                def requested = details.requested
                if (requested.group == 'com.android.support') {
                        if (!requested.name.startsWith("multidex")) {
                                details.useVersion '25.4.0'
                        }
                }
        }
}
...

1 个答案:

答案 0 :(得分:0)

它可能是由代码缩小(混淆)引起的。 如果您正在使用proguard(并且在发布版本上发生了问题), 您可能想要查看您使用的某个库是否需要手动添加一些proguard规则。

祝你好运。