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

末鹿安然 提交于 2019-12-07 09:59:34

问题


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?


回答1:


You can set this:

android.ndk {
   platformVersion = "19"
}

See https://stackoverflow.com/a/33982735/3115956 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).



来源:https://stackoverflow.com/questions/34532383/how-do-you-set-app-platform-in-gradle-ndk-plug-in-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!