Android Fabric crashlytics 问题

Android Fabric crashlytics issue

添加 fabric crashlytics 后出现错误,因为在 android 4.4

中未找到 MultiPartBuildEntry 的 class 定义错误
 java.lang.NoClassDefFoundError: org.apache.http.entity.mime.MultipartEntityBuilder
 at clovewearable.commons.social.server.SignUpService.generateMultiPartPayload(SignUpService.java:171)
 at clovewearable.commons.social.server.SignUpService.triggerAPICall(SignUpService.java:110)
 at clovewearable.commons.social.ui.SignUpFragment.triggerAPICall(SignUpFragment.java:585)
 at clovewearable.commons.social.ui.SignUpFragment.validateNormalSignIn(SignUpFragment.java:388)
 at clovewearable.commons.social.ui.SignUpFragment.onClick(SignUpFragment.java:427)
 at android.view.View.performClick(View.java:4640)
 at android.view.View$PerformClick.run(View.java:19421)
 at android.os.Handler.handleCallback(Handler.java:733)
 at android.os.Handler.dispatchMessage(Handler.java:95)
 at android.os.Looper.loop(Looper.java:136)
 at android.app.ActivityThread.main(ActivityThread.java:5476)
 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:1268)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
 at dalvik.system.NativeStart.main(Native Method)

要在 class 中初始化结构,我们必须启动结构催化剂。

onCreate 中使用以下行来初始化结构:

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

您的 Application.class 应该从 MultiDexApplication

扩展

为此你应该在你的代码中添加这样的代码gradle

android {
defaultConfig {
...
   multiDexEnabled true
}  
dependencies {
...
   compile 'com.android.support:multidex:1.0.2'
}