David_Wang
David_Wang

Reputation: 670

Android compile project with target="android-19" failed

Masters,

Recently I am trying to build android project with gradle, and since there one API(@JavascriptInterface annotation) I need to use is only up to api level 17, so I changed my targetAPILevel to 19 in project properties. And it works well when I build the project from Eclipse(Right click on project and Run Android Application).

But when I tried to build the project by gradlew in terminal, it seems it never use target level 19 to build the project. Here is part of the build.gradle file as follow:

android {

// target = 'android-19'
compileSdkVersion 19
buildToolsVersion '19.0.1'

}

Can anyone help me what I did wrong in here, please? Thank you very much.

Upvotes: 0

Views: 981

Answers (1)

Gabriele Mariotti
Gabriele Mariotti

Reputation: 364271

TargetSdkVersion and compileSdkVersion are different parameters.

In eclipse, you set the target in your Manifest, and set the api used to compile with right click -> properties -> Android Manu.

In your build.gradle you should use something like this:

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }   
}

Upvotes: 2

Related Questions