参考这篇文章,是否有人有一对 build.gradle 文件来演示从 android 库项目中引用 Crashlytics 的基本设置?
即使我遵循了上面最初提到的帖子提供的建议,我也会收到以下错误。
这是我的 App gradle.build 文件。
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
apply plugin: 'android'
apply plugin: 'crashlytics'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile project(':Common.Logger')
compile project(':Common.ProtocolBuffer')
compile project(':Common.Utils')
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:support-v4:+'
compile 'com.crashlytics.android:crashlytics:1.+'
androidTestCompile 'com.jayway.android.robotium:robotium-solo:5.1'
androidTestCompile 'junit:junit:4.11'
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
buildTypes {
debug {
buildConfigField "boolean", "USE_LOGCAT", "true"
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics=false
}
release {
runProguard true
debuggable false
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
buildConfigField "boolean", "USE_LOGCAT", "false"
buildConfigField "boolean", "USE_CRASHLYTICS", "true"
ext.enableCrashlytics=true
}
}
sourceSets {
packagingOptions {
exclude 'LICENSE.txt'
}
lintOptions {
abortOnError false
}
}
}
这是我当前的库 build.gradle 文件。
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.+'
}
}
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile 'com.crashlytics.android:crashlytics:1.+'
}
apply plugin: 'android-library'
android {
compileSdkVersion 19
buildToolsVersion '19.0.3'
buildTypes {
debug {
buildConfigField "boolean", "USE_LOGCAT", "true"
buildConfigField "boolean", "USE_CRASHLYTICS", "false"
ext.enableCrashlytics=false
}
release {
buildConfigField "boolean", "USE_LOGCAT", "false"
buildConfigField "boolean", "USE_CRASHLYTICS", "true"
ext.enableCrashlytics=true
}
}
sourceSets {
lintOptions {
abortOnError false
}
}
}
不久前,Crashlytics 支持人员告诉我,只需在 buildType 中使用“ext.enableCrashlytics”标志即可。
以下是使用上述 gradle 构建文件时出现的当前 gradle 错误。
Error:A problem occurred configuring root project 'ManageMyVMail.Android'.
> A problem occurred configuring project ':Common.ProtocolBuffer'.
> Could not resolve all dependencies for configuration ':Common.ProtocolBuffer:_debugCompile'.
> Could not find any version that matches com.crashlytics.android:crashlytics:1.+.
Required by:
ManageMyVMail.Android:Common.ProtocolBuffer:unspecified > ManageMyVMail.Android:Common.Logger:unspecified
作为第二个问题,如果我想在通过当前的 gradle 构建错误后从两个项目中使用它们,是否需要在两个文件中创建相同的 buildConfigField 值集。我对 Gradle 和 Android Studio 还很陌生,但是搜索 Intertron 还没有得到答案。
先感谢您。