我有一个Android项目,带有一个主模块以及多个其他子模块。通过更新项目级别的build.gradle和主模块build.gradle,我成功地将Crashlytics集成到了项目中:
项目级gradle:
main.c:5:10: warning: iteration 9 invokes undefined behavior [-Waggressive-loop-optimizations]
buf[i] = i;
~~~~~~~^~~
main.c:4:2: note: within this loop
for (int i = 0; i < 10; i++)
^~~
主模块build.gradle:
buildscript {
repositories {
jcenter()
maven {url 'https://maven.google.com'}
maven {url 'https://maven.fabric.io/public'}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
jcenter()
google()
maven {url 'https://maven.fabric.io/public'}
}
}
模块module-wifinetwork的build.gradle(每个模块都相似):
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
...
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
implementation project(':modules:sensordata:collection:ambient:module-wifinetwork')
...
}
repositories {
maven { url 'https://dl.bintray.com/rvalerio/maven' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
jcenter()
}
我的问题是来自主模块的崩溃报告已正确发送到Firebase后端,而其他模块中的崩溃报告却没有正确发送,即使它们已正确识别,因为如果我将此命令放在子目录的类中-模块:
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility = 1.8
sourceCompatibility = 1.8
}
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
}
我收到以下信息:
Crashlytics.getInstance().crash();
任何线索为什么这在子模块中不起作用?谢谢
答案 0 :(得分:0)
我发现了问题,只需要重建项目即可。因此,解决方案是将以下元素添加到项目级别的build.gradle和主模块build.gradle中,而无需在单个模块build.gradle中添加任何内容。然后清理并重建您的项目。
项目级build.gradle:
buildscript {
repositories {
...
maven {url 'https://maven.fabric.io/public'}
...
}
dependencies {
...
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
...
maven {url 'https://maven.fabric.io/public'}
}
}
主模块build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
...
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
repositories {
...
}