0

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.

David_Wang
  • 652
  • 9
  • 20
  • Possible duplicate of [Android Proguard Javascript Interface Fail](https://stackoverflow.com/questions/6271485/android-proguard-javascript-interface-fail) – Jason Aller Aug 28 '19 at 04:14

1 Answers1

2

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"
    }   
}
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • Hi, Thanks. But I think your way is correct, and mine is correct, too. The only thing I found what will cause the problem is the Proguard. If my build doesn't include proguard, it will run correctly. Don't know what mistake I did in there, will check then. – David_Wang Apr 03 '14 at 05:23