[SOLVED]Fail When Build Native

Hi, I just setting up my project to run in android, and I’ve followed tutorial but got an error when running command ‘cocos compile -p android’ then this is my terminal error :

i’m using android studio instead eclipse. can anyone help me ?

So I tried, but did not have Android-22, let me grab it and try again.

The path to te project should not contain spaces, so you have two options:

  1. Modify Cocos Development folder name to CocosDevelopment so you’ll have /Users/adesuluh/Desktop/CocosDevelopment/FlappyBird/proj.android-studio
  2. Proceed like me and move your project to Desktop and the problem will be solved

And one more thing, if you want to compile for Android Studio use cocos compile -p android --android-studio instead of cocos compile -p android.

the OP is using that…but true about spaces. Android-22 is still downloading for me, but I will verify I can successfully compile once it is done.

Ops, didn’t see in the pic that he has used the right command in the terminal. Sorry, my mistake.

thanks for your help, i’m waiting for your verify. btw how to change the version android platform in console ?

I’ll try change my project folder, when i’m done, i’ll try to post here. Thanks for your answer

So it works for me.

I did this:

cocos new Testing -p com.com.com -l cpp -d .
cd Testing/
cocos compile -p android --android-studio

after some time and it downloading gradle stuff I get:

BUILD SUCCESSFUL

Total time: 11.086 secs
PREDEX CACHE HITS:   0
PREDEX CACHE MISSES: 2
Stopped 0 compiler daemon(s).

This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.html
Move apk to /Users/jtsm/Desktop/Testing/bin/debug/android
Build succeed.

In proj.android-studio/app/jni/Application.mk add this line APP_PLATFORM := android-19 (change 19 with the version you want, by default I think it’s 21 and you’ll get errors on devices that run android versions lower than 5 but if you leave it 19 it’ll work on devices with android versions lower than 5 as well). I hope that I understood the question correctly.

Hi, i follow your advice and change folder withoust space, and yes it’s working. But when the compile running with downloading a lot of material, then it’s happened :

failed find target android 22 ?

You don’t have Android SDK 22

oh i got it, i should update it thank you for your helping, very appreciated it.

Yes, run android and add Android-22

I’m sorry, im done with android 22 and then compile again, this error keep showing, im i think have installed all android 22 through sdk manager :smile:

Do you have env variables defined, like this, in your ~/.bash_profile?

# Add environment variables for Android Cocos2d-x development
export NDK_ROOT=/usr/local/Cellar/android-ndk/r10d
export PATH=$NDK_ROOT:$PATH
export ANDROID_HOME=/usr/local/opt/android-sdk
export ANDROID_SDK_ROOT=/usr/local/Cellar/android-sdk/24.2
export PATH=$ANDROID_SDK_ROOT:$PATH
export PATH=$ANDROID_SDK_ROOT/tools:$ANDROID_SDK_ROOT/platform-tools:$PATH
export ANT_ROOT=/Applications/Cocos/tools/ant/bin
export PATH=$ANT_ROOT:$PATH

Thanks al for your helpl it’s work! :smile: