我试图在我的应用上设置Crashlytics。
我下载并安装了Android Studio插件,创建了一个帐户并成功将其集成到我的应用程序 - 我可以登录并查看仪表板,我可以看到我的应用程序,但看不到任何崩溃。
在adb日志中,触发异常后,我看到:
11-09 11:55:17.231 17255-17297/com.example.test I/CrashlyticsCore: Crashlytics report upload complete: 5A03D19A02E8-0001-4367-EE097F894C89
但是如果你看一下完整的日志,你会看到一些奇怪的东西:
11-09 11:55:15.251 17255-17507/com.example.test W/dalvikvm: threadid=77: thread exiting with uncaught exception (group=0x2c6e8fc0)
11-09 11:55:15.331 17255-17297/com.example.test E/CrashlyticsCore: An error occurred in the fatal exception logger
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:121)
at android.hardware.SystemSensorManager.<init>(SystemSensorManager.java:50)
at android.app.ContextImpl$26.createService(ContextImpl.java:417)
at android.app.ContextImpl$ServiceFetcher.getService(ContextImpl.java:207)
at android.app.ContextImpl.getSystemService(ContextImpl.java:1250)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:416)
at android.content.ContextWrapper.getSystemService(ContextWrapper.java:416)
at io.fabric.sdk.android.services.common.CommonUtils.getProximitySensorEnabled(CommonUtils.java:416)
at com.crashlytics.android.core.CrashlyticsController.writeSessionEvent(CrashlyticsController.java:1245)
at com.crashlytics.android.core.CrashlyticsController.writeFatal(CrashlyticsController.java:885)
at com.crashlytics.android.core.CrashlyticsController.access$400(CrashlyticsController.java:66)
at com.crashlytics.android.core.CrashlyticsController$7.call(CrashlyticsController.java:318)
at com.crashlytics.android.core.CrashlyticsController$7.call(CrashlyticsController.java:311)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at io.fabric.sdk.android.services.common.ExecutorUtils$1$1.onRun(ExecutorUtils.java:75)
at io.fabric.sdk.android.services.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:30)
at java.lang.Thread.run(Thread.java:856)
11-09 11:55:15.541 17255-17507/com.example.test E/AndroidRuntime: FATAL EXCEPTION: Thread-261
java.lang.RuntimeException: test
at com.example.test.system.HODSystem.calcSystemStatus(HODSystem.java:574)
at com.example.test.system.HODSystem.UpdateAllSystemCalculation(HODSystem.java:798)
at com.example.test.bl.SystemCalculator.run(SystemCalculator.java:21)
at java.lang.Thread.run(Thread.java:856)
11-09 11:55:16.021 17255-17257/com.example.test D/dalvikvm: GC_CONCURRENT freed 659K, 5% free 24065K/25219K, paused 11ms+41ms, total 348ms
11-09 11:55:16.021 17255-17255/com.example.test D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 138ms
11-09 11:55:16.021 17255-17506/com.example.test D/dalvikvm: WAIT_FOR_CONCURRENT_GC blocked 104ms
11-09 11:55:17.231 17255-17297/com.example.test I/CrashlyticsCore: Crashlytics report upload complete: 5A03D19A02E8-0001-4367-EE097F894C89
以下是我的一些配置:
的build.gradle:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
repositories {
jcenter()
}
}
应用程序/的build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion = 22
buildToolsVersion = "25.0.2"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'mips', 'mips64'
}
externalNativeBuild {
cmake {
cppFlags.addAll(['-std=c++11', '-fexceptions', '-Wall', '-Wno-literal-suffix','-g3'])
}
}
}
buildTypes {
release {
minifyEnabled = false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = false
}
debug {
debuggable = true
ext.enableCrashlytics = true
}
dev {
initWith debug
ext.enableCrashlytics = true
}
}
externalNativeBuild {
cmake {
path "CMakeLists.txt"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.6@aar') {
transitive = true;
}
}
crashlytics {
enableNdk true
androidNdkOut 'src/main/cpp'
androidNdkLibsOut 'src/main/cpp'
}
申请类:
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
Fabric.with(getApplicationContext(), new Crashlytics(), new CrashlyticsNdk());
}
@Override
public void onTerminate() {
super.onTerminate();
System.exit(0);
}
}
我还试图在活动的onCreate中抛出一个运行时异常但仍然得到相同的结果。
我想也许System.exit(0)
导致了这个问题,但我试图删除它,但我仍然遇到了这个错误。
在Google中没有找到任何关于此的内容。需要你的帮助。
谢谢!