现在我正在尝试将Fabric与Crashlytics(https://docs.fabric.io/android/fabric/integration.html)集成到现有的Android应用程序中。
按照Fabric提供的集成说明,我将apply plugin: 'com.android.application'
添加到我的" build.grade(Project.NumenuApp)"的根目录中。文件。我点击同步Gradle,它失败,我收到此错误Error:Cause: buildToolsVersion is not specified.
Android工作室声明我的插件应该在Module而不是Project级别声明。
我已经在" build.grade(Module:app)"中设置了buildTools。文件。我的问题是为什么会发生这种情况,我该怎么做才能解决这个问题?我在下面发布了我的代码。提前致谢。 - 阿德里安
build.grade(Project:NumenuApp)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.grade(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.numenu.numenuapp"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
答案 0 :(得分:8)
您必须从build.gradle (Project:NumenuApp)
中删除这些行。您正在使用错误的文件来应用插件。
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
同时在build.gradle (Module:app)
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
答案 1 :(得分:3)
这是我的build.gradle(Module:app)
文件,我有一个有效的CrashLytics,我的project.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.ws.cs"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
packagingOptions {
exclude "/lib/arm64-v8a/librealm-jni.so"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.google.code.gson:gson:2.2.2'
compile 'io.realm:realm-android:0.82.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
}
答案 2 :(得分:0)
请检查 app.gradle 中的这一行是否存在
buildToolsVersion“25.0.3”
实施例
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "kc.care.task"
minSdkVersion 20
targetSdkVersion 25
versionCode 23
versionName "3.7"
multiDexEnabled = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}