Search code examples
androidantcocos2d-x

Unable to run the cocos2dx sample game from android studio


I try to run the cocos2dx sample program but I get the following error Is there something wrong with the path or the setting ? I would love to hear from you!

Mic-no-MacBook-Pro:CocoFolder mic$ cocos run -s ~/Desktop/CocoFolder/NewGame -p android --android-studio
/Users/mic/.bash_profile: line 8: export: `PATH:/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk:/usr/local/lib/node_modules/ant/ant/bin:/usr/local/lib/node_modules/ant/ant:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/mic/Desktop/CocoFolder/cocos2d-x-3.14.1/tools/cocos2d-console/bin:/Users/mic/Desktop/CocoFolder/android-ndk-r14b:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home:/usr/local/lib/node_modules/ant/ant:/usr/local/lib/node_modules/ant/ant/bin': not a valid identifier
/Users/mic/.bash_profile: line 11: export: `PATH:/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk:/usr/local/lib/node_modules/ant/ant/bin:/usr/local/lib/node_modules/ant/ant:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/mic/Desktop/CocoFolder/cocos2d-x-3.14.1/tools/cocos2d-console/bin:/Users/mic/Desktop/CocoFolder/android-ndk-r14b:/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home:/usr/local/lib/node_modules/ant/ant:/usr/local/lib/node_modules/ant/ant/bin': not a valid identifier
Building mode: debug
Using Android Studio project : /Users/mic/Desktop/CocoFolder/NewGame/proj.android-studio
running: '/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk/tools/android update project -t android-13 -p /Users/mic/Desktop/CocoFolder/NewGame/proj.android-studio/app'

*************************************************************************
The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
*************************************************************************
Invalid or unsupported command "update project -t android-13 -p /Users/mic/Desktop/CocoFolder/NewGame/proj.android-studio/app"

This is inside the bash profile

export ANT_HOME=/usr/local/lib/node_modules/ant/ant
export PATH=$ANT_HOME:$PATH

export ANT_ROOT=/usr/local/lib/node_modules/ant/ant/bin
export PATH=$ANT_ROOT:$PATH

export ANDROID_HOME=/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk
export PATH:$ANDROID_HOME:$PATH

export ANDROID_SDK_ROOT=/Users/mic/Downloads/adt-bundle-mac-x86_64-20140702/sdk
export PATH:$ANDROID_SDK_ROOT:$PATH

export ANT_HOME=/usr/local/lib/node_modules/ant/ant
export PATH=$ANT_HOME:$PATH

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
export PATH=$JAVA_HOME:$PATH

export NDK_ROOT=/Users/mic/Desktop/CocoFolder/android-ndk-r14b
export PATH=$NDK_ROOT:$PATH

export COCOS2D_CONSOLE_ROOT=/Users/mic/Desktop/CocoFolder/cocos2d-x-3.14.1/tools/cocos2d-console/bin

export PATH=$COCOS2D_CONSOLE_ROOT:$PATH

Solution

  • compile run -p android --android-studio doesn't work because it also depends on android.bat utility.

    You're using Android SDK tools build 25.3.X version and now, the android command is gone. Android SDK tools release note here. The android command & ant scripts are removed.

    One solution is downgrade to previous version (25.2.3) of SDK tools from this page: https://developer.android.com/studio/index.html (see the bottom of the page) and then replaced tools folder in the Android sdk with the previous one.

    Another solution download cocos2d-console from GitHub repo (v3 branch) and extract all files and put into /cocos2d-x/tools/cocos2d-console folder after deleting old files of cocos2d-console folder.