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

35,830

Solution 1

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.

Solution 2

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.

Solution 3

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.

Share:
35,830
glo
Author by

glo

Updated on July 09, 2022

Comments

  • glo
    glo almost 2 years

    I am getting the following warning when compiling my cocos2d-x project with cygwin.

    `/cygdrive/e/project/MyGame/proj.android `
    /cygdrive/e/android-ndk-r8e/build/core/add-application.mk:128: Android NDK: WARNING:APP_PLATFORM android-9 is larger than android:minSdkVersion 8 in ./AndroidManifest.xml
    

    I am using NDK version r8e. My minimum SDK version is 8 in my AndroidManifest.xml but i do not specify APP_PLATFORM as android-9 anywhere. How can i change this to 8.

    Can anyone tell me how to solve this warning as I think this may cause issues.

  • radj
    radj almost 11 years
    Does this have any impact?
  • j.holetzeck
    j.holetzeck almost 11 years
    Well, you must be sure that your native code satisfy this constraint, e.g. works on the given platform.
  • Auras
    Auras over 7 years
    For gradle experimental see this answer: stackoverflow.com/a/34535385/91226