在我的android应用中:
app / build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.29.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
def AAVersion = '4.6.0'
dependencies {
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation('com.crashlytics.sdk.android:crashlytics:2.7.0@aar') { transitive = true; }
在我的android应用中:
import android.app.Application;
import android.content.Context;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.core.CrashlyticsCore;
import io.fabric.sdk.android.Fabric;
import android.annotation.SuppressLint;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
public class MainApp extends Application {
@Override
public void onCreate() {
APP_PROFILE_URL = BuildConfig.API_BASE_URL;
super.onCreate();
initCrashLytics();
}
private void initCrashLytics() {
Crashlytics crashlyticsKit = new Crashlytics.Builder()
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
.build();
Fabric.with(this, crashlyticsKit, new Crashlytics());
}
并且成功在Android 5.0及更高版本上运行。
很好。
但是,当我在Android 4.4上启动我的应用程序时。我收到错误消息:
E/AndroidRuntime( 5581): FATAL EXCEPTION: main
E/AndroidRuntime( 5581): Process: com.myproject.debug, PID: 5581
E/AndroidRuntime( 5581): java.lang.RuntimeException: Unable to get provider com.crashlytics.android.CrashlyticsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.crashlytics.android.CrashlyticsInitProvider" on path: DexPathList[[zip file "/data/app/com.myproject.debug-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myproject.debug-1, /vendor/lib, /system/lib]]
E/AndroidRuntime( 5581): at android.app.ActivityThread.installProvider(ActivityThread.java:4793)
E/AndroidRuntime( 5581): at android.app.ActivityThread.installContentProviders(ActivityThread.java:4385)
E/AndroidRuntime( 5581): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4325)
E/AndroidRuntime( 5581): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
E/AndroidRuntime( 5581): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
E/AndroidRuntime( 5581): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 5581): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 5581): at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime( 5581): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5581): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 5581): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime( 5581): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime( 5581): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5581): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.crashlytics.android.CrashlyticsInitProvider" on path: DexPathList[[zip file "/data/app/com.myproject.debug-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.myproject.debug-1, /vendor/lib, /system/lib]]
E/AndroidRuntime( 5581): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime( 5581): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
E/AndroidRuntime( 5581): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
E/AndroidRuntime( 5581): at android.app.ActivityThread.installProvider(ActivityThread.java:4778)
E/AndroidRuntime( 5581): ... 12 more
W/ActivityManager( 1616): Force finishing activity com.myproject.debug/com.myproject.SplashActivity_