我看不到 crashlytics。我的 build.gradle 檔案中有這個。不確定,我已經完成了他們所說的所有實踐,并在為我的專案設定 Firebase 時從檔案中復制粘貼了確切的 google-service.json 檔案。任何人都可以看到為什么它不起作用謝謝!
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
testImplementation 'junit:junit:4. '
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:28.4.2')
implementation 'com.google.firebase:firebase-analytics'
}
我的專案級 build.gradle 檔案。
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.3"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31"
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我檢查了在 firebase 控制臺中啟用的 crashlytics 儀表板。仍然無法捕獲崩潰。我在 android 中使用運行時例外導致崩潰
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
throw RuntimeException("Test Crash")
}
}
uj5u.com熱心網友回復:
我認為您錯過了在專案和應用程式級別 build.gradle.kts 中應用插件的部分(檔案中的第 3 步)
build.gradle.kts(project)
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'
build.gradle.kts(app)
apply plugin: 'com.google.firebase.crashlytics'
您可以使用此處的檔案逐步完成
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/336916.html
