cocos2d-X doesn't find android platform
Asked Answered
V

7

6

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

But when I run

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
Volsung answered 8/5, 2014 at 19:45 Comment(0)
P
0

These tutorials cover all steps:

http://www.cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android

and

http://www.cocos2d-x.org/wiki/How_to_Build_an_Android_Project_with_Eclipse

Prearrange answered 8/5, 2014 at 20:9 Comment(1)
I am pretty sure people all people asking have already checked those resources.Oona
A
4

How to specify the android platform:

Use '--ap 19|20', e.g.,

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

Auguste answered 2/8, 2014 at 19:9 Comment(1)
Guess this appeared after cocos2d-x 3.1. I have just installed 3.2 and your way it worked! Thank you!Remorseless
A
4

If

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

does not work (Using NDK r10b)

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

For me, it is now:

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

Auguste answered 27/9, 2014 at 15:53 Comment(0)
C
2

This issue will occur when your environment variable not set properly, I suggest you to set your environment variables properly and then restart command prompt or terminal then execute cocos compile -s projectname -p android if your project compile successfully then you can run this project. hope this helps

Catarina answered 25/7, 2015 at 5:53 Comment(0)
O
1

I am able to solve similar issue just as this one. I am running Cocos2d-x v3.6 and able to have this error on both r9d and r10e NDKs. Whenever I ran the 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 Running command: compile Building mode: debug Android platform not specified, searching a default one... Can't find right android-platform for project : "C:\Cocos2d-x\cocos2d-x-3.6\tests\cpp-tests\proj.android". The android-platform should be equal/larger than 10 Build dynamic library for project [ C:\Cocos2d-x\cocos2d-x-3.6\build..\tests/cpp-tests ] fails!

Also this error appear as well when I tried to create a project and running build_native.py from the project itself.

I am able to figure out maybe because the ANT_ROOT, NDK_BUILD and ANDROID_SDK_ROOT are not being registered into the cocos command properly.

Here what I did:

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

I went ahead and tried this tutorial.

I got a slightly different output message than that of the screenshot. I got mine failed but at least, I no longer have the error that says Android platform not specified.

UPDATE: It seems the error is being caused by ANT_ROOT. There is tricky part here. You specify the ANT_ROOT without ; or \ at the end of the path when you insert the path by My Computer > Right Click > Properties > Advance System Settings > Environment Variables (Assuming you are using windows). The cocos build appends an additional directory off from ant and in effect it destroys the actual path during build. Replacing it manually and then restarting console returns back where I was before. I simply did what I have done awhile back (Deleting all environment variable related to Cocos2d-x, this time including ANT_ROOT) and it works! I am able to build the apk and run it on my phone!

Hope this helps someone in the future.

Oona answered 23/5, 2015 at 6:40 Comment(2)
So what does you ANT_ROOT variable look like? I can't get it to work properly, mine is C:\apache-ant-1.9.5\bin.Particiaparticipant
@Moberg, I got the same path. What error are you getting?Oona
D
1

I just open sdk manager and install newest sdk from list (by default the application offers you to install necessary packages if you didn't have them). You can open sdk manager with command android sdk

Discontinuation answered 9/2, 2016 at 11:25 Comment(0)
S
1

In my case, I add the %ANDROID_SDK%\tools to my path, so the 'android.bat' file get accessible to cocos console. then cocos run will read the correct platform form file project.properties in your android project.

Simferopol answered 6/11, 2016 at 9:56 Comment(0)
P
0

These tutorials cover all steps:

http://www.cocos2d-x.org/wiki/How_to_run_cpp-tests_on_Android

and

http://www.cocos2d-x.org/wiki/How_to_Build_an_Android_Project_with_Eclipse

Prearrange answered 8/5, 2014 at 20:9 Comment(1)
I am pretty sure people all people asking have already checked those resources.Oona

© 2022 - 2024 — McMap. All rights reserved.