How do you set APP_PLATFORM in Gradle NDK plug-in in Android Studio?
Asked Answered
S

1

4

I'm building an app with an NDK library using Android Studio 1.5.1 and the Gradle experimental plugin 0.4.0.

Even though the Gradle config is set as such (with minSdkVersion.apiLevel = 18), it seems like the NDK library is still compiled for android-21:

compileOptions.with {
    sourceCompatibility=JavaVersion.VERSION_1_7
    targetCompatibility=JavaVersion.VERSION_1_7
}

android {
    compileSdkVersion = 23
    buildToolsVersion = "23.0.2"

    defaultConfig.with {
        applicationId = "net.pol_online.hyper"
        minSdkVersion.apiLevel = 18  // Android 4.3 Jelly Bean
        targetSdkVersion.apiLevel = 23  // Android 6.0 Marshmallow
    }
}

Is it because APP_PLATFORM is not automatically set by the Gradle NDK support based on the min SDK version? If so how do you fix this?

Saga answered 30/12, 2015 at 15:31 Comment(1)
Possible duplicate of Gradle: change NDK build target independent from the SDK build targetLatvia
S
6

You can set this:

android.ndk {
   platformVersion = "19"
}

See https://mcmap.net/q/393959/-gradle-change-ndk-build-target-independent-from-the-sdk-build-target for details on this. (In practice, I think your library is built targeting android-23, which has the same effect as targeting android-21 - compileSdkVersion is the one that affects it (for both the java and native code, unless the native one is overridden).

Sideway answered 30/12, 2015 at 18:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.