Android NDK: WARNING: APP_PLATFORM android-9 is larger than android:minSdkVersion 8

瘦欲@ 提交于 2019-11-27 13:02:31

It seems that you are using Android-9 as runtime. You can put APP_PLATFORM := android-8 in your Application.mk file and the warning will disappear.

The reason behind the warning/error is it wants to let you know it's compiling the native code for a target platform higher than your "minimum" spcefied in the manifest. It's basically saying 'be careful about using features not supported on the older OS. The Application.mk change is okay and shouldn't have any real adverse affects on the compiled code.

~~ Alternative solutions.

For r8 you can change the build settings to consider it a warning rather than an error. This worked in r8 but is only a partial fix in r9.

For NDK rev r9 (works in others revs too but location/line# may differ)

${NDK}/build/core/add-application.mk line 138

add "#" at start of the line.

# $(call __ndk_info,WARNING: APP_PLATFORM $(APP_PLATFORM) is larger than android:minSdkVersion $(APP_MIN_PLATFORM_LEVEL) in $(APP_MANIFEST))

One character, 30 second fix ... go debug native code.

If you do want to compile your native library for a newer version than your minSdkVersion, you can just configure Eclipse to change the error to a warning. This can be useful if you know that your Java code is NOT going to load the native library in older versions of Android. (Warning: If you don't guarantee that, then loading your native library on versions of Android older than what's specified in your APP_PLATFORM can fail and crash the app if there are unsatisfied dynamic library links - e.g. if your APP_PLATFORM is 9 and you use OpenSLES, this will fail if you try to use JNI on Android 2.2 or earlier. But as long as your Java side knows about this and ensures that loadLibrary is never called on older versions, then you're fine.)

You can change the Eclipse settings by following these steps, provided by a someone from Google (at this link) (but also, see my IMPORTANT note below):

In eclipse:

- Window -> Preferences -> C/C++ -> Build -> Settings
- Select CDT GNU C/C++ Error Parser
- In the Error Parser options at the bottom, add a new entry with the following contents:

Severity: Warning
Pattern: (.*?):(\d+): Android NDK: WARNING:(.*) 
File: $1
Line: $2
Description: $3

IMPORTANT! What the Google guy didn't note is that you also need to use the "Move Up" button in the settings to move your new rule to the top because otherwise some other more generic rules overshadow it and it doesn't work.

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