Android Studio - 错误构建 - Android 任务已经创建

Ren*_*rio 3 android build android-studio

构建项目时出现以下错误:

错误:(2, 0) Android 任务已经创建。调用 android.applicationVariants、android.libraryVariants 或 android.testVariants 时会发生这种情况。一旦调用了这些方法,就无法继续配置模型。

根构建.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'
}
Run Code Online (Sandbox Code Playgroud)

应用程序构建.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')
}
Run Code Online (Sandbox Code Playgroud)

pyu*_*s13 6

您的顶级build.gradle文件应该只包含项目所有模块的通用配置。

进行以下更改:

build.gradle文件应该只有这一段代码

buildscript {
      repositories {
        jcenter()
      }
      dependencies {
        classpath 'com.android.tools.build:gradle:1.1.0'
      }
}

allprojects{
    repositories {
        jcenter()
      }
}
Run Code Online (Sandbox Code Playgroud)