Cocos2d-X does not find Android platform

I am using cocos2d-X v3 and I created a new cocos2d-X project following this tutorial .

But when I started

cocos run -s ~ / MyCompany / MyGame -p android

I get this error:

building apk Android platform not specified, searching a default one... Can't find right android-platform for project : "/Users/filipeferminiano/MyCompany/MyGame/proj.android". The android-platform should be equal/larger than 10 
+6
source share
7 answers

How to specify the Android platform:

Use '--ap 19 | 20 'for example

cocos run -s ~ / MyCompany / MyGame -p android -ap 20

+4
source

If

cocos run -s ~ / MyCompany / MyGame -p android -ap 20

does not work (using NDK r10b)

You can use the android list command to list all available target platforms

For me it is now:

cocos run -s ~ / MyCompany / MyGame -p android --ap android-20

+4
source

This problem occurs when the environment variable is not configured properly, I suggest you set the environment variables correctly, then restart the command line or terminal, then run cocos compile -s projectname -p android if your project compiles successfully, you can start this project. hope this helps

+2
source

I can solve a similar problem like this one. I am running Cocos2d-x v3.6 and may have this error on both the N9 r9d and r10e NDKs. Whenever I ran android-build.py from the cpp-tests folder, I always got this error:

cocos compile -p android -s C: \ Cocos2d-x \ cocos2d-x-3.6 \ build .. \ tests / cpp-tests -ndk-mode debug Run the command: compilation Build mode: debug Android platform is not specified, search by by default ... It is not possible to find a suitable android platform for the project: "C: \ Cocos2d-x \ cocos2d-x-3.6 \ tests \ cpp-tests \ proj.android". The Android platform must be equal to / greater than 10. It is not possible to build a dynamic library for the project [C: \ Cocos2d-x \ cocos2d-x-3.6 \ build .. \ tests / cpp-tests]!

Also, this error also appears when I tried to create a project and run build_native.py from the project itself.

I can understand, perhaps because ANT_ROOT, NDK_BUILD and ANDROID_SDK_ROOT are not registered in the cocos command properly.

Here is what I did:

  • I deleted all Cocos2d-x related environment variables (ANT_ROOT, NDK_BUILD and ANDROID_SDK_ROOT).
  • I went into the root folder of Cocos2d-x and ran setup.py again
  • This time Cocos2d-x asks for new paths (since we deleted them)
  • I added the path manually, and then restarted the console.

I went ahead and tried this tutorial .

I got a slightly different output message than the screen. I did not succeed, but at least I no longer have an error that says that the Android platform is not listed.

UPDATE: It seems that the error was caused by ANT_ROOT. Here's the hard part. You specify ANT_ROOT without ; or \ at the end of the path when pasting the path My Computer> Right Click> Properties> Advance System Settings> Environment Variables (Assume you are using windows). The cocos construct adds an extra directory from ant and actually destroys the actual path at build time. Replacing it manually and then rebooting the console will return to where I was before. I just did what I did a while ago (removing the entire environment variable related to Cocos2d-x, this time, including ANT_ROOT), and it works! I can build apk and run it on my phone!

Hope this helps someone in the future.

+1
source

I just open the sdk manager and install the latest sdk from the list (by default, the application offers you to install the necessary packages if you do not have them). You can open sdk manager with android sdk command

+1
source

In my case, I am adding% ANDROID_SDK% \ tools to my path, so the file 'android.bat' is made available to the cocos console. then starting cocos will read the correct project.properties platform form file in your Android project.

+1
source

All Articles