Android Studio-错误生成-Android任务已创建 [英] Android Studio - Error Building - Android tasks have already been created
问题描述
在构建项目时出现以下错误:
Getting the following error when building the project:
错误:(2,0)Android任务已经创建. 调用android.applicationVariants时会发生这种情况, android.libraryVariants或android.testVariants. 一旦调用了这些方法,就不可能 继续配置模型.
Error:(2, 0) Android tasks have already been created. This happens when calling android.applicationVariants, android.libraryVariants or android.testVariants. Once these methods are called, it is not possible to continue configuring the model.
root build.gradle:
Root build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'android'
android {
compileSdkVersion 'Google Inc.:Google APIs:19'
buildToolsVersion '19.1.0'
defaultConfig {
versionCode 5
versionName '5'
targetSdkVersion 19
minSdkVersion 10
applicationId 'tsp.movil'
}
}
dependencies {
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.android.support:support-v4:22.1.1'
}
应用程序build.gradle:
App build.gradle:
android {
compileSdkVersion 'Google Inc.:Google APIs:19'
buildToolsVersion '19.1.0'
defaultConfig {
applicationId "tsp.movil"
minSdkVersion 10
targetSdkVersion 19
versionCode 5
versionName '5'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile 'com.google.android.gms:play-services:+'
compile files('libs/zbar.jar')
}
推荐答案
您的顶级 build.gradle 文件应仅具有项目所有模块的通用配置.
Your Top Level build.gradle file should only have the configuration common for all modules of your project.
进行以下更改:
根 build.gradle 文件应仅包含这段代码
Root build.gradle file should have only this piece of code
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects{
repositories {
jcenter()
}
}
这篇关于Android Studio-错误生成-Android任务已创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!