Search code examples
androidc++cocos2d-x

Why I can't set android-platform lower then 22 when I compile?


When I compile standard hello world project, created by cocos-console (cocos2d-x 3.6) with --ap android-16 (android platform 16) it wrights:

The android-platform of project "E:\projects\cocos_projects\test\proj.android" s
hould be equal/larger than 22, but 16 is specified.

In AndroidManifest.xml I have: <uses-sdk android:minSdkVersion="9"/>.

In SDK manager I have installed all platforms and at ...\sdk\platforms I have 8, 10, 15-22 and MNC folders.


Solution

  • @Andrey answer is basically right, but I'll complete it with some missing information for the sake of any other cocos2d-x developers looking for how to solve this.

    This error:

    The android-platform of project "E:\projects\cocos_projects\test\proj.android" should be equal/larger than 22, but 16 is specified.

    appears when you tell to the cocos command to use an Android API version (--ap android-XX) which conflicts with your project properties configuration.

    Let's say your proj.android/project.properties is something like this:

    target=android-22
    android.library.reference.1=../cocos2d/cocos/platform/android/java
    

    So, before launching a command that request to use a different Android API version (ex. cocos compile -p android --ap android-16), you should manually edit project.properties and changed the target key to a value that matches the new Android API version you want to use.