Fabric/Crashlytics NoClassDefFoundError 仅在某些设备上

Posted

技术标签:

【中文标题】Fabric/Crashlytics NoClassDefFoundError 仅在某些设备上【英文标题】:Fabric/Crashlytics NoClassDefFoundError only on certain devices 【发布时间】:2015-08-19 13:37:13 【问题描述】:

我在 Google Play 中看到与 Fabric/Crashlytics 相关的崩溃。这发生在我从普通 Crashlytics 更新到新的 Fabric Crashlytics 之后。我只能在我的一台设备(Galaxy S2)上重现它。我拥有的所有其他设备(Nexus 5 和 S4)都没有崩溃。这是堆栈跟踪:

08-19 09:32:26.328    7084-7084/com.tsm.countryjam D/dalvikvm﹕ WAIT_FOR_CONCURRENT_GC blocked 0ms
08-19 09:32:26.653    7084-7088/com.tsm.countryjam D/dalvikvm﹕ GC_CONCURRENT freed 251K, 12% free 9567K/10823K, paused 12ms+2ms, total 70ms
08-19 09:32:26.653    7084-7084/com.tsm.countryjam D/dalvikvm﹕ WAIT_FOR_CONCURRENT_GC blocked 42ms
08-19 09:32:26.653    7084-7100/com.tsm.countryjam D/dalvikvm﹕ WAIT_FOR_CONCURRENT_GC blocked 42ms
08-19 09:32:26.668    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Failed resolving Lcom/crashlytics/android/beta/Beta; interface 9027 'Lio/fabric/sdk/android/services/common/DeviceIdentifierProvider;'
08-19 09:32:26.668    7084-7084/com.tsm.countryjam W/dalvikvm﹕ Link of class 'Lcom/crashlytics/android/beta/Beta;' failed
08-19 09:32:26.668    7084-7084/com.tsm.countryjam E/dalvikvm﹕ Could not find class 'com.crashlytics.android.beta.Beta', referenced from method com.crashlytics.android.Crashlytics.<init>
08-19 09:32:26.668    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to resolve new-instance 1791 (Lcom/crashlytics/android/beta/Beta;) in Lcom/crashlytics/android/Crashlytics;
08-19 09:32:26.668    7084-7084/com.tsm.countryjam D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x000a
08-19 09:32:26.668    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Failed resolving Lcom/crashlytics/android/beta/Beta; interface 9027 'Lio/fabric/sdk/android/services/common/DeviceIdentifierProvider;'
08-19 09:32:26.668    7084-7084/com.tsm.countryjam W/dalvikvm﹕ Link of class 'Lcom/crashlytics/android/beta/Beta;' failed
08-19 09:32:26.668    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lcom/crashlytics/android/beta/Beta;)
08-19 09:32:26.673    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Failed resolving Lcom/crashlytics/android/beta/Beta; interface 9027 'Lio/fabric/sdk/android/services/common/DeviceIdentifierProvider;'
08-19 09:32:26.673    7084-7084/com.tsm.countryjam W/dalvikvm﹕ Link of class 'Lcom/crashlytics/android/beta/Beta;' failed
08-19 09:32:26.673    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lcom/crashlytics/android/core/PinningInfoProvider;)
08-19 09:32:26.673    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lcom/crashlytics/android/core/PinningInfoProvider;)
08-19 09:32:26.673    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lcom/crashlytics/android/core/PinningInfoProvider;)
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lcom/crashlytics/android/core/CrashlyticsListener;)
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to find class referenced in signature (Lcom/crashlytics/android/core/CrashlyticsListener;)
08-19 09:32:26.678    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Failed resolving Lcom/crashlytics/android/beta/Beta; interface 9027 'Lio/fabric/sdk/android/services/common/DeviceIdentifierProvider;'
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ Link of class 'Lcom/crashlytics/android/beta/Beta;' failed
08-19 09:32:26.678    7084-7084/com.tsm.countryjam D/dalvikvm﹕ DexOpt: unable to opt direct call 0x3474 at 0x0f in Lcom/crashlytics/android/Crashlytics;.<init>
08-19 09:32:26.678    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Failed resolving Lcom/crashlytics/android/answers/SessionEventTransform; interface 9072 'Lio/fabric/sdk/android/services/events/EventTransform;'
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ Link of class 'Lcom/crashlytics/android/answers/SessionEventTransform;' failed
08-19 09:32:26.678    7084-7084/com.tsm.countryjam E/dalvikvm﹕ Could not find class 'com.crashlytics.android.answers.SessionEventTransform', referenced from method com.crashlytics.android.answers.Answers.initializeSessionAnalytics
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to resolve new-instance 1784 (Lcom/crashlytics/android/answers/SessionEventTransform;) in Lcom/crashlytics/android/answers/Answers;
08-19 09:32:26.678    7084-7084/com.tsm.countryjam D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0004
08-19 09:32:26.678    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Could not find method io.fabric.sdk.android.services.common.CommonUtils.logControlledError, referenced from method com.crashlytics.android.answers.Answers.initializeSessionAnalytics
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to resolve static method 59049: Lio/fabric/sdk/android/services/common/CommonUtils;.logControlledError (Landroid/content/Context;Ljava/lang/String;Ljava/lang/Throwable;)V
08-19 09:32:26.678    7084-7084/com.tsm.countryjam D/dalvikvm﹕ VFY: replacing opcode 0x77 at 0x0194
08-19 09:32:26.678    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Could not find method io.fabric.sdk.android.services.settings.Settings.getInstance, referenced from method com.crashlytics.android.answers.Answers.doInBackground
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to resolve static method 59331: Lio/fabric/sdk/android/services/settings/Settings;.getInstance ()Lio/fabric/sdk/android/services/settings/Settings;
08-19 09:32:26.678    7084-7084/com.tsm.countryjam D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x000c
08-19 09:32:26.678    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Could not find method io.fabric.sdk.android.services.common.CommonUtils.getStringsFileValue, referenced from method com.crashlytics.android.answers.Answers.getOverridenSpiEndpoint
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to resolve static method 59043: Lio/fabric/sdk/android/services/common/CommonUtils;.getStringsFileValue (Landroid/content/Context;Ljava/lang/String;)Ljava/lang/String;
08-19 09:32:26.678    7084-7084/com.tsm.countryjam D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0008
08-19 09:32:26.678    7084-7084/com.tsm.countryjam E/dalvikvm﹕ Could not find class 'io.fabric.sdk.android.services.persistence.FileStoreImpl', referenced from method com.crashlytics.android.answers.Answers.getSdkDirectory
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to resolve new-instance 9090 (Lio/fabric/sdk/android/services/persistence/FileStoreImpl;) in Lcom/crashlytics/android/answers/Answers;
08-19 09:32:26.678    7084-7084/com.tsm.countryjam D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0001
08-19 09:32:26.678    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Could not find method io.fabric.sdk.android.services.common.Crash$FatalException.getSessionId, referenced from method com.crashlytics.android.answers.Answers.onException
08-19 09:32:26.678    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to resolve virtual method 59056: Lio/fabric/sdk/android/services/common/Crash$FatalException;.getSessionId ()Ljava/lang/String;
08-19 09:32:26.678    7084-7084/com.tsm.countryjam D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000b
08-19 09:32:26.683    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Could not find method io.fabric.sdk.android.services.common.Crash$LoggedException.getSessionId, referenced from method com.crashlytics.android.answers.Answers.onException
08-19 09:32:26.683    7084-7084/com.tsm.countryjam W/dalvikvm﹕ VFY: unable to resolve virtual method 59058: Lio/fabric/sdk/android/services/common/Crash$LoggedException;.getSessionId ()Ljava/lang/String;
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000b
08-19 09:32:26.683    7084-7084/com.tsm.countryjam I/dalvikvm﹕ Failed resolving Lcom/crashlytics/android/answers/SessionEventTransform; interface 9072 'Lio/fabric/sdk/android/services/events/EventTransform;'
08-19 09:32:26.683    7084-7084/com.tsm.countryjam W/dalvikvm﹕ Link of class 'Lcom/crashlytics/android/answers/SessionEventTransform;' failed
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/dalvikvm﹕ DexOpt: unable to opt direct call 0x3455 at 0x0c in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/dalvikvm﹕ DexOpt: unable to opt direct call 0xe6da at 0x19 in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/dalvikvm﹕ DexOpt: unable to opt direct call 0xe78c at 0x36 in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam W/dalvikvm﹕ Unable to resolve superclass of Lcom/crashlytics/android/answers/SessionAnalyticsFilesManager; (9073)
08-19 09:32:26.683    7084-7084/com.tsm.countryjam W/dalvikvm﹕ Link of class 'Lcom/crashlytics/android/answers/SessionAnalyticsFilesManager;' failed
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/dalvikvm﹕ DexOpt: unable to opt direct call 0x342a at 0x4b in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x5e1e at 0x72 in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x5e1c at 0x7e in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x5e21 at 0x8a in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/dalvikvm﹕ DexOpt: unable to opt direct call 0xe78f at 0x115 in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/dalvikvm﹕ DexOpt: unable to opt direct call 0xe78f at 0x17d in Lcom/crashlytics/android/answers/Answers;.initializeSessionAnalytics
08-19 09:32:26.683    7084-7084/com.tsm.countryjam I/dalvikvm﹕ DexOpt: unable to optimize instance field ref 0x5e91 at 0x20 in Lcom/crashlytics/android/answers/Answers;.doInBackground
08-19 09:32:26.683    7084-7084/com.tsm.countryjam I/dalvikvm﹕ DexOpt: unable to optimize instance field ref 0x5e8c at 0x22 in Lcom/crashlytics/android/answers/Answers;.doInBackground
08-19 09:32:26.683    7084-7084/com.tsm.countryjam I/dalvikvm﹕ DexOpt: unable to optimize instance field ref 0x5e8e at 0x2a in Lcom/crashlytics/android/answers/Answers;.doInBackground
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/dalvikvm﹕ DexOpt: unable to opt direct call 0xe7ac at 0x07 in Lcom/crashlytics/android/answers/Answers;.getSdkDirectory
08-19 09:32:26.683    7084-7084/com.tsm.countryjam D/AndroidRuntime﹕ Shutting down VM
08-19 09:32:26.683    7084-7084/com.tsm.countryjam W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4127b2a0)
08-19 09:32:26.683    7084-7084/com.tsm.countryjam E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: com.crashlytics.android.beta.Beta
            at com.crashlytics.android.Crashlytics.<init>(Crashlytics.java:29)
            at com.tsm.events.application.TownsquareEvents.onCreate(TownsquareEvents.java:59)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1014)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4251)
            at android.app.ActivityThread.access$1400(ActivityThread.java:140)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1297)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4921)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
            at dalvik.system.NativeStart.main(Native Method)

这是我的 build.gradle 的内容:

buildscript 
    repositories 
        jcenter()
        maven  url 'https://maven.fabric.io/public' 
    

    dependencies 
        classpath 'com.android.tools.build:gradle:1.0.+'
        classpath 'io.fabric.tools:gradle:1.+'
    

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

repositories 
    jcenter()
    flatDir 
        dirs 'libs'
    
    maven  url 'https://maven.fabric.io/public' 



android 
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig 
        applicationId "com.tsm.events"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0.0"
        multiDexEnabled = true
    
    dexOptions 
        javaMaxHeapSize "4g"
    
    buildTypes 
        debug 
            debuggable true
        
        release 
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        
    



dependencies 
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':libraries:ResideMenu')
    //compile 'com.android.support:support-v4:20.0.+'
    compile 'com.android.support:support-v4:22.0.+'
    compile files('libs/universal-image-loader-1.9.3.jar')
    compile 'io.realm:realm-android:0.81.1'
    compile 'se.emilsjolander:stickylistheaders:2.5.2'
    compile 'com.google.android.gms:play-services:6.5.87'
    compile 'com.parse.bolts:bolts-android:1.+'
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile('com.crashlytics.sdk.android:crashlytics:2.4.0@aar') 
        transitive = true
    
    // Twitter Kit
    compile('com.twitter.sdk.android:twitter:1.6.0@aar') 
        transitive = true
    
    compile('com.twitter.sdk.android:tweet-composer:0.8.0@aar') 
        transitive = true;
    
    compile 'com.facebook.android:facebook-android-sdk:3.20.0'
    compile 'com.google.maps.android:android-maps-utils:0.3+'
    compile(name: 'estimote-sdk-preview', ext: 'aar')
    compile files('libs/biweekly-0.4.2.jar')
    compile files('libs/jackson-core-2.5.2.jar')

【问题讨论】:

您使用哪个版本的 crashlytics?另外,请发布您的 build.gradle 文件的内容。 更新了 build.gradle 的内容。我相信我正在使用 Crashlytics 2.4.0。 【参考方案1】:

我只是凭直觉想通了!最近升级到新的 Fabric 框架后不得不添加多 dex 支持,感觉可能是我没做对。所以在添加了这些额外的更改后,现在它不再崩溃了:

在我的 build.gradle 中,我添加了增量设置:

dexOptions 
        incremental true
        javaMaxHeapSize "4g"
    

还有一个额外的依赖:

compile 'com.android.support:multidex:'

在我的应用程序类上,我正在扩展 MultiDexApplication:

public class TownsquareEvents extends android.support.multidex.MultiDexApplication

【讨论】:

我有同样的问题,我有除此之外的所有 multidex 代码:“incremental true”。该问题目前在某些设备上重现,我没有并且无法检查它们。那里是否需要“增量真实”参数? 可能对某人有所帮助的其他信息:在我的应用程序类中,我保留了 MultiDex.install(this);在 attachBaseContext() 中,但它应该在 super() 调用之后的 onCreate() 中。这为我解决了这个问题。希望这会有所帮助 这行得通,但我收到了关于 DexOptions.incremental 在 2018 年底过时的警告,这并没有给我带来温暖的模糊感。【参考方案2】:

请构建这个:编译'com.android.support:multidex:1.0.1'

并在您的应用程序类中添加此方法:

           protected void attachBaseContext(Context base) 
               super.attachBaseContext(base);
               MultiDex.install(this);
            

【讨论】:

【参考方案3】:

如果您正确使用MultiDex,但仍然遇到此错误,可能是因为您使用的是Proguard,而MultiDex 不知道要保留哪些类。

因此,请务必将您的 MultiDex 保留文件与您的 Proguard .pro 文件“同步”。

示例

buildTypes 
   // other stuff...

    release 
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        ext.enableCrashlytics = true

        //
        // IMPORTANT PART:
        //
        // tell your MultiDex to keep the classes you defined in your Proguard .pro file.
        multiDexKeepProguard file('proguard-rules.pro')
    

通过这样做,您无需手动指定multidex.keep 文件!

有关multiDexKeepProguard here 和来自 Google 的 full developer docs 的更多信息。

【讨论】:

如果您同时使用 proguard 和 multidex,这是关键。 当你同时使用ProguardMultiDex 时肯定是答案,我希望我早点知道。【参考方案4】:

两年后的附加信息:问题似乎只出现在运行 Android

【讨论】:

【参考方案5】:

首先检查是否添加了 Fabric SDK,如果出现此错误,请检查以下文件。

01-26 12:15:46.186  32094-32094/com.example.android I/SELinux﹕ Function: selinux_android_load_priority [0], There is no sepolicy file.
01-26 12:15:46.186  32094-32094/com.example.android I/SELinux﹕ SELinux: VERIFYSIG  File Open Unsuccessful:
01-26 12:15:46.186  32094-32094/com.example.android I/SELinux﹕ Function: selinux_android_load_priority , spota verifySig or checkHash fails. priority version is VE=SEPF_GT-I9500_4.4.2_0018
01-26 12:15:46.186  32094-32094/com.example.android I/SELinux﹕ selinux_android_seapp_context_reload: seapp_contexts file is loaded from /seapp_contexts
01-26 12:15:46.191  32094-32094/com.example.android E/dalvikvm﹕ >>>>> Normal User
01-26 12:15:46.191  32094-32094/com.example.android E/dalvikvm﹕ >>>>> com.example.android [ userId:0 | appId:10288 ]
01-26 12:15:46.191  32094-32094/com.example.android D/dalvikvm﹕ Late-enabling CheckJNI
01-26 12:15:46.261  32094-32094/com.example.android E/dalvikvm﹕ Could not find class 'io.fabric.sdk.android.Kit[]', referenced from method com.example.android.ExampleApplication.onCreate
01-26 12:15:46.261  32094-32094/com.example.android W/dalvikvm﹕ VFY: unable to resolve new-array 10457 ([Lio/fabric/sdk/android/Kit;) in Lcom/example/android/ExampleApplication;
01-26 12:15:46.261  32094-32094/com.example.android D/dalvikvm﹕ VFY: replacing opcode 0x23 at 0x0007
01-26 12:15:46.261  32094-32094/com.example.android W/dalvikvm﹕ Unable to resolve superclass of Lcom/crashlytics/android/Crashlytics; (8949)
01-26 12:15:46.261  32094-32094/com.example.android W/dalvikvm﹕ Link of class 'Lcom/crashlytics/android/Crashlytics;' failed
01-26 12:15:46.261  32094-32094/com.example.android D/dalvikvm﹕ DexOpt: unable to opt direct call 0x3705 at 0x12 in Lcom/example/android/ExampleApplication;.onCreate
01-26 12:15:46.261  32094-32094/com.example.android I/MultiDex﹕ VM with version 1.6.0 does not have multidex support
01-26 12:15:46.261  32094-32094/com.example.android I/MultiDex﹕ install
01-26 12:15:46.261  32094-32094/com.example.android I/MultiDex﹕ MultiDexExtractor.load(/data/app/com.example.android-1.apk, false)
01-26 12:15:46.271  32094-32094/com.example.android I/MultiDex﹕ loading existing secondary dex files
01-26 12:15:46.271  32094-32094/com.example.android I/MultiDex﹕ load found 1 secondary dex files
01-26 12:15:46.276  32094-32094/com.example.android I/MultiDex﹕ install done
01-26 12:15:46.281  32094-32094/com.example.android I/PersonaManager﹕ getPersonaService() name persona_policy
01-26 12:15:46.291  32094-32094/com.example.android D/AndroidRuntime﹕ Shutting down VM
01-26 12:15:46.291  32094-32094/com.example.android W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41887c08)
01-26 12:15:46.296  32094-32094/com.example.android E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.android, PID: 32094
    java.lang.NoClassDefFoundError: io.fabric.sdk.android.Kit[]
            at com.example.android.ExampleApplication.onCreate(ExampleApplication.java:16)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1025)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4581)
            at android.app.ActivityThread.access$1600(ActivityThread.java:161)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1325)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:157)
            at android.app.ActivityThread.main(ActivityThread.java:5356)
            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:1265)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
            at dalvik.system.NativeStart.main(Native Method)
01-26 12:15:52.016  32094-32094/com.example.android I/Process﹕ Sending signal. PID: 32094 SIG: 9

build.gradle

  buildscript 
    repositories 
        maven  url 'https://maven.fabric.io/repo' 
    

    dependencies 
        classpath 'io.fabric.tools:gradle:1.14.4'
    

apply plugin: 'com.android.application'
//Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'

repositories 
    maven  url 'https://raw.github.com/beshkenadze/dozer/mvn-repo' 
    maven  url 'https://maven.fabric.io/repo' 


...

dependencies 
    compile fileTree(dir: 'libs', include: ['*.jar'])
    ...
    // Crashlytics Kit
    compile('com.crashlytics.sdk.android:crashlytics:2.2.0@aar') 
        transitive = true
    


afterEvaluate 
    tasks.matching 
        it.name.startsWith('dex')
    .each  dx ->
        if (dx.additionalParameters == null) 
            dx.additionalParameters = []
        
        dx.additionalParameters += '--multi-dex'
        dx.additionalParameters += "--main-dex-list=$projectDir/multidex.keep".toString()
    

ExampleApplication.java

    package com.example.android;

import android.support.multidex.MultiDexApplication;

import com.crashlytics.android.Crashlytics;

import io.fabric.sdk.android.Fabric;

public class ExampleApplication extends MultiDexApplication 

    private ExampleManager mManager;

    @Override
    public void onCreate() 
        super.onCreate();
        Fabric.with(this, new Crashlytics());

        mManager = ExampleManager.getInstance();
        mManager.init(getApplicationContext());
    

multidex.keep

android/support/multidex/BuildConfig.class
android/support/multidex/MultiDex$V14.class
android/support/multidex/MultiDex$V19.class
android/support/multidex/MultiDex$V4.class
android/support/multidex/MultiDex.class
android/support/multidex/MultiDexApplication.class
android/support/multidex/MultiDexExtractor$1.class
android/support/multidex/MultiDexExtractor.class
android/support/multidex/ZipUtil$CentralDirectory.class
android/support/multidex/ZipUtil.class
com/example/android/ExampleApplication.class

progurad-rules.pro

-dontoptimize
-dontobfuscate
#-optimizationpasses 5
-printusage unused.txt
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-keepattributes SourceFile,LineNumberTable
-keepattributes *Annotation*
-keepattributes InnerClasses

#Project

-keep public class com.example.android.**  *; 
-dontwarn com.example.android.**
-dontwarn com.example.android.db.**
-keep public class com.example.android.db.**  *; 

# javascriptInterface Proguard RULES
-keepclassmembers class * 
    @android.webkit.JavascriptInterface <methods>;


-keepattributes JavascriptInterface
-keep public class com.example.android.ui.view.EditorView$EditorInterface
-keep public class * implements com.example.android.ui.view.EditorView$EditorInterface
-keepclassmembers class com.example.android.ui.view.EditorView$EditorInterface 
    <methods>;


# Libs
#-libraryjars libs/AF-Android-SDK-v2.3.1.11.jar
#-libraryjars libs/aws-android-sdk-1.7.1.1-core.jar
#-libraryjars libs/aws-android-sdk-1.7.1.1-s3.jar
#-libraryjars libs/FlurryAnalytics_3.3.3.jar
#-libraryjars libs/Parse-1.4.3.jar
#-libraryjars libs/google-play-services-STRIPPED.jar
#-libraryjars ../bypass-library/libs/bypass.jar

# Models
-keep class com.example.android.api.data.**  *; 
-keep class com.example.android.model.**  *; 

# Bypass
-keep class in.uncod.android.bypass.**  *; 

# Butterknife
-dontwarn butterknife.internal.**
-keep class **$$ViewInjector  *; 
-keepnames class *  @butterknife.InjectView *;

# Parse.com
-dontwarn com.parse.FacebookAuthenticationProvider*
-dontwarn com.parse.FacebookAuthenticationProvider
-dontwarn com.parse.ParseFacebookUtils
-dontwarn com.parse.**
-keep class com.parse.**  *; 

# AWS SDK for Android
-keep class org.apache.commons.logging.**                *; 
-keep class com.amazonaws.services.sqs.QueueUrlHandler   *; 
-keep class com.amazonaws.javax.xml.transform.sax.*      public *; 
-keep class com.amazonaws.javax.xml.stream.**            *; 
-keep class com.amazonaws.services.**.model.*Exception*  *; 
-keep class org.codehaus.**                              *; 
-keep class com.amazonaws.internal.config.**  *; 
-keepattributes Signature,*Annotation*

-dontwarn javax.xml.stream.events.**
-dontwarn com.fasterxml.jackson.**
-dontwarn org.apache.commons.logging.impl.**
-dontwarn org.apache.http.conn.scheme.**
-dontwarn com.amazonaws.AmazonWebServiceRequest
-dontwarn com.amazonaws.ClientConfiguration
-dontwarn com.amazonaws.DefaultRequest
-dontwarn com.amazonaws.RequestClientOptions
-dontwarn com.amazonaws.auth.**
-dontwarn com.amazonaws.http.AmazonHttpClient
-dontwarn com.amazonaws.http.ExecutionContext
-dontwarn com.amazonaws.http.impl.**
-dontwarn com.amazonaws.internal.config.HttpClientConfig
-dontwarn com.amazonaws.internal.config.InternalConfig
-dontwarn com.amazonaws.internal.config.SignerConfig
-dontwarn com.amazonaws.metrics.ServiceLatencyProvider
-dontwarn com.amazonaws.org.apache.http.**
-dontwarn com.amazonaws.retry.RetryPolicy
-dontwarn com.amazonaws.util.**
-dontwarn com.amazonaws.org.joda.**
-dontwarn com.amazonaws.javax.**
-dontwarn org.apache.commons.**

# Android
-keep public class * extends android.app.Activity
-keep public class * extends android.webkit.WebView
-keep public class * extends android.app.Application
-keep public class * extends android.app.Fragment
-keep public class * extends android.app.ListActivity
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keepclasseswithmembers class * 
    native <methods>;


-keepclasseswithmembers class * 
    public <init>(android.content.Context, android.util.AttributeSet);


-keepclasseswithmembers class * 
    public <init>(android.content.Context, android.util.AttributeSet, int);


-keepclassmembers enum * 
    public static **[] values();
    public static ** valueOf(java.lang.String);


-keepclassmembers class * 
    public void onClickUpdate(android.view.View);


-keep class * implements android.os.Parcelable 
  public static final android.os.Parcelable$Creator *;


-keep class * extends java.util.ListResourceBundle 
   protected Object[][] getContents();



# Google API
-keep class com.google.**  *;
-keep interface com.google.**  *;
-dontwarn com.google.**

-dontwarn sun.misc.Unsafe
-dontwarn com.google.common.collect.MinMaxPriorityQueue
-keepattributes *Annotation*,Signature
-keep class * extends com.google.api.client.json.GenericJson 
*;


-keep class * extends java.util.ListResourceBundle 
    protected Object[][] getContents();


-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable 
    public static final *** NULL;


-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * 
    @com.google.android.gms.common.annotation.KeepName *;


-keepnames class * implements android.os.Parcelable 
    public static final ** CREATOR;



# Squareup
-dontwarn com.squareup.okhttp.**

# Joda-Time
-dontwarn org.joda.time.**

# EventBus
-keepclassmembers class ** 
    public void onEvent*(**);


# Annotation
-keepattributes *Annotation*

# Retrofit
-keep class com.google.gson.**  *; 
-keep class com.google.inject.**  *; 
-keep class org.apache.http.**  *; 
-keep class org.apache.james.mime4j.**  *; 
-keep class javax.inject.**  *; 
-keep class retrofit.**  *; 
-keep class com.example.testobfuscation.**  *; 
-keepattributes Signature
-keep class sun.misc.Unsafe  *; 
-dontwarn rx.**

# Scribe oAuth
-keep class org.scribe.** 
    *;

-keep class javax.xml.bind.DatatypeConverter
-dontwarn javax.xml.bind.DatatypeConverter
-dontwarn org.scribe.**

#Roundview
-dontwarn com.makeramen.**

#android.support.v4
-dontwarn android.support.v4.**

-keepclasseswithmembers class io.fabric.sdk.android.** 
  *;


-keep public class * extends io.fabric.sdk.android.Kit.**
-keep class * implements io.fabric.sdk.android.KitGroup.**

【讨论】:

【参考方案6】:

我正在尝试通过将 Crashlytics 更新到 2.9.1 来修复此错误。根据https://docs.fabric.io/android/changelog.html#february-28-2018:

修复了当 Firebase Core 未明确包含为依赖项时导致 Firebase Crashlytics 无法启动的错误。

我的build.gradle 现在改为:

implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') 
    transitive = true;

编辑:没有帮助。在 Android 4.x 上,Crashlytics 崩溃。多么讽刺。

【讨论】:

以上是关于Fabric/Crashlytics NoClassDefFoundError 仅在某些设备上的主要内容,如果未能解决你的问题,请参考以下文章

iOS(Fabric):Crashlytics 在启动时崩溃应用程序

Fabric(Crashlytics):最新版本在“最新版本”部分不可见

Fabric/Crashlytics NoClassDefFoundError 仅在某些设备上

Fabric Crashlytics 与 Angular Web 应用程序

如何从 Fabric Crashlytics 迁移到 Firebase Crashlytics?

支持 Watch 的 iOS 应用程序的 Crashlytics / Fabric 分布?