简体   繁体   中英

Android Studio won't compile

I am trying to compile (debug) the "HelloWorld" Chromecast Android app supplied by Google on their GitHub page.

After doing numerous updates to the SDK and Android Studio, I am now totally stuck on getting this to run.

I have not changed any code that was supplied.

The current error I get when clicking "debug" is:

"NoSuchMethodError: com.android.builder.model.ProductFlavor.getMinSdkVersion()I: com.android.builder.model.ProductFlavor.getMinSdkVersion()I"

I cannot find any information on this error.

Build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
    }
}

repositories {
    mavenCentral()
}

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 19
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:19.0.1'
    compile 'com.android.support:mediarouter-v7:19.0.1'
    compile 'com.google.android.gms:play-services:4.2.+'
}

您可以尝试进入清单文件,并可以更改sdk的最低版本

Split your gradle.build:

On the gradle.build of your project leave:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.9.+'
   }
}

repositories {
    mavenCentral()
}

And on the gradle.build of your module declare:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion "19"

    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 19
    }

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            res.srcDirs = ['res']
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:19.0.1'
    compile 'com.android.support:mediarouter-v7:19.0.1'
    compile 'com.google.android.gms:play-services:4.2.+'
}

Gradle配置文件 Put the first code on project gradle configuration and the secod part of code on module gradle configuration file.

Pretty sure you just need to update your Gradle tools version. This line:

classpath 'com.android.tools.build:gradle:0.9.+'

should be:

classpath 'com.android.tools.build:gradle:0.12.+'

Android Studio 0.8+ requires at least 0.12 to properly build your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM