我试图使Crashlytics正常工作,但是即使我按照所有步骤进行操作,我仍然似乎在Crashlytics中看不到任何错误。
可以请你看看吗?
这是我用来开始崩溃的代码:
Crashlytics.getInstance().crash(); // Force a crash
我的应用程式摇篮:
apply plugin: 'com.android.application'
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
lintOptions {
disable 'MissingTranslation'
}
}
}
buildToolsVersion '27.0.3'
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
maven { url 'https://maven.fabric.io/public' }
}
}
repositories {
mavenCentral()
}
apply plugin: 'io.fabric'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:25.+'
implementation 'com.android.support:design:25.+'
implementation 'com.android.support:support-v4:25.+'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.roughike:bottom-bar:2.3.1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
// Required only if Facebook login support is r6equired
implementation 'com.facebook.android:facebook-android-sdk:4.27.0'
// Required only if Twitter login support is required
implementation("com.twitter.sdk.android:twitter-core:3.0.0@aar") { transitive = true }
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
//compile 'com.google.firebase:firebase-crash:16.0.0'
// Displaying images
implementation 'com.github.bumptech.glide:glide:3.7.0'
//implementation 'com.google.android.gms:play-services:15.0.0'
implementation 'com.google.android.gms:play-services-auth:16.0.0'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-identity:15.0.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.3'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.1'
}
}
}
}
apply plugin: 'com.google.gms.google-services'
我的构建平台(我还从Firebase设置中获取了一个新的google-services.json文件):
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的清单
<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="blah">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CLEAR_APP_CACHE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/SplashScreenTheme">
// metadata for Facebook login
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"
tools:replace="android:value" />
<activity
android:name=".SplashScreen"
android:screenOrientation="portrait">
-
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="orientation|screenSize"
android:screenOrientation="portrait"
android:theme="@style/Theme.TransNav" />
<activity
android:name=".QRCodeScannerActivity"
android:theme="@style/Theme.TransNav" />
//Facebook activities for Facebook login
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.gms.vision.DEPENDENCIES"
android:value="barcode" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_logo_without_text" />
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/white" />
<meta-data
android:name="io.fabric.ApiKey"
android:value="blh"/>
<service android:name=".MyFirebaseInstanceIDService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />
</intent-filter>
</service>
<service android:name=".MyFirebaseMessaging">
-
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
</application>
</manifest>
答案 0 :(得分:0)
有时Firebase Crashlytics需要花费一些时间来注册崩溃。请稍等,如果您已按照正确的步骤操作,我相信崩溃会在一段时间内出现。
编辑:
请遵循以下步骤:
向您的项目级build.gradle 文件添加Crashlytics存储库和相关性。
maven {
url 'https://maven.fabric.io/public'
}
dependencies {
// ...
classpath 'io.fabric.tools:gradle:1.25.4'
}
allprojects {
repositories {
maven {
url 'https://maven.google.com/'
}
}
}
此外,请选中 Crashlytics需要Google Services插件3.1.2或更高版本。在项目的build.gradle依赖项中检查com.google.gms:google-services版本号。
2。)将Crashlytics依赖项添加到您的应用级 build.gradle :
apply plugin: 'io.fabric'
dependencies {
// ...
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.5'
}
将其保留为“强制崩溃”按钮:
Button crashButton = new Button(this);
crashButton.setText("Crash!");
crashButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Crashlytics.getInstance().crash(); // Force a crash
}
});
addContentView(crashButton, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
答案 1 :(得分:0)
尝试像文档here中一样启用调试模式。
1)将这些行添加到清单
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
2)初始化Crashlytics时,请启用调试模式。
final Fabric fabric = new Fabric.Builder(this)
.kits(new Crashlytics())
.debuggable(true) // Enables Crashlytics debugger
.build();
Fabric.with(fabric);