android - Gradle: change NDK build target independent from the SDK build target -


in past used eclipse ndk projects, android.mk file suited compiling ndk api level 9 while letting app (sdk) compile on api level 22. seems not possible when using experimental gradle build system (2.5) android studio 1.3 rc1.

what can compile ndk on api level 9?

my typical android.mk file looks this:

app_platform := android-9 app_stl := stlport_static app_abi :=  # enable c++11 extentions in source code app_cppflags += -std=c++11  #enable optimalization in release mode app_optim := release 

my new gradle file looks this:

apply plugin: 'com.android.model.application'  model {     android {         compilesdkversion = 22         buildtoolsversion = "23.0.0 rc3"          defaultconfig.with {             applicationid = "com.example"             minsdkversion.apilevel = 9             targetsdkversion.apilevel = 22             versioncode = 1             versionname = "1.0"         }     }      android.ndk {         modulename = "nativelibrary"         cppflags   += "-i${file("src/main/jni/some_folder")}".tostring()         cppflags   += "-std=c++11"          //what should added here compile ndk on api 9???          cflags += "-dndebug"         cflags += "-fvisibility=hidden"         cppflags += "-fvisibility=hidden"          ldlibs     += ["log"]         stl         = "stlport_static"     }      android.buildtypes {         release {             isminifyenabled = true             proguardfiles += file('d:/path/proguard-rules.pro')         }     } }  dependencies {     compile filetree(dir: 'libs', include: ['*.jar'])     compile 'com.android.support:support-v4:22.2.0' } 

i investigated gradle source , seems ndk build target hard-coded same compilesdkversion. there method avoid or alter behavior?

ndkcompile.groovy (make file creation)

// target iandroidtarget target = getplugin().loadedsdkparser.target if (!target.isplatform()) {     target = target.parent } commands.add("app_platform=" + target.hashstring()) 

sdk.groovy (target fetched form compilesdkversion)

public sdkparser loadparser() {     checknotnull(extension, "extension has not been set")      // call getparser ensure it's created.     sdkparser theparser = getparser()      if (!issdkparserinitialized) {         string target = extension.getcompilesdkversion()         if (target == null) {             throw new illegalargumentexception("android.compilesdkversion missing!")         }          fullrevision buildtoolsrevision = extension.buildtoolsrevision         if (buildtoolsrevision == null) {             throw new illegalargumentexception("android.buildtoolsversion missing!")         }          theparser.initparser(target, buildtoolsrevision, logger)          issdkparserinitialized = true     }      return theparser } 

if using experimental plugin version 0.4. can set

android.ndk {    platformversion = "19" } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -