3.6 C++ Android Build Issue on OSX

Hi All, I’m having some issue building for android with the latests 3.6. I’ve even tried with a fresh project to eliminate any of my mistakes. Here’s what I’ve done.

Create New Project :

cocos new -l cpp -p com.tee.test Test

Running command: new
Copy template into /Users/Rick/Projects/cocos/Test
Copying cocos2d-x files...
Rename project name from 'HelloCpp' to 'Test'
Replace the project name from 'HelloCpp' to 'Test'
Replace the project package name from 'org.cocos2dx.hellocpp' to 'com.tee.test'
Replace the mac bundle id from 'org.cocos2dx.hellocpp' to 'com.tee.test'
Replace the ios bundle id from 'org.cocos2dx.hellocpp' to 'com.tee.test'

Attempt to compile for android :

cd Test/
cocos compile -p android
Running command: compile
Building mode: debug
Android platform not specified, searching a default one...
running: '/Users/Rick/Library/Developer/android-sdk-macosx/tools/android update project -t android-22 -p /Users/Rick/Projects/cocos/Test/proj.android'

Updated project.properties
Updated local.properties
Updated file /Users/Rick/Projects/cocos/Test/proj.android/proguard-project.txt
GoogleInc.:GoogleAPIs:22 is not a valid android target platform.

Note The error : GoogleInc.:GoogleAPIs:22 is not a valid android target platform.

I verified my env setup:

ANDROID_SDK_ROOT=/Users/Rick/Library/Developer/android-sdk-macosx
COCOS_CONSOLE_ROOT=/Applications/Cocos/frameworks/cocos2d-x-3.6/tools/cocos2d-console/bin
COCOS_TEMPLATES_ROOT=/Applications/Cocos/frameworks/cocos2d-x-3.6/templates
ANT_ROOT=/Applications/Cocos/tools/ant/bin
COCOS_FRAMEWORKS=/Applications/Cocos/frameworks
NDK_ROOT=/Users/Rick/Library/Developer/android-ndk-r9d

I’ve verified all these paths exist.

Next I checked the available android targets via :

android list target

returns :

Available Android targets:
----------
id: 1 or "android-22"
     Name: Android 5.1.1
     Type: Platform
     API level: 22
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 2 or "Google Inc.:Google APIs:22"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 5.1.1 (API level 22)
     Libraries:
      * com.android.future.usb.accessory (usb.jar)
          API for USB Accessories
      * com.google.android.media.effects (effects.jar)
          Collection of video effects
      * com.google.android.maps (maps.jar)
          API for Google Maps
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64 
indent preformatted text by 4 spaces

The Android SDK manager GUI also shows version 22 installed. Everything seems in order to me, I am rather new at android dev, so I may be missing something obvious. The only thing I noted, that seemed odd is that in the error, GoogleInc.:GoogleAPIs:22 is not a valid android target platform., the whitespace seems to be stripped from the target name compared to what android list target returns. I seems the only file that makes reference to the api is :

cocos2d/cocos/platform/android/java/project.properties

which contains whitespace that matches android list target:

target=Google Inc.:Google APIs:22

Any thoughts on what I might be doing wrong?

Thanks
Rick

So, I install Android using brew and It is installing r10 for me.

According to this: http://cocos2d-x.org/programmersguide/B/

I tried with android-ndk-r10d, and have the same results.

Also, building the cpp-tests also fails.

python android-build.py -p 22 cpp-tests
cocos compile -p android -s /Applications/Cocos/frameworks/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...
running: '/Users/Rick/Library/Developer/android-sdk-macosx/tools/android update project -t android-22 -p /Applications/Cocos/frameworks/cocos2d-x-3.6/tests/cpp-tests/proj.android'

Updated project.properties
Updated local.properties
Updated file /Applications/Cocos/frameworks/cocos2d-x-3.6/tests/cpp-tests/proj.android/proguard-project.txt
GoogleInc.:GoogleAPIs:22 is not a valid android target platform.
Build dynamic library for project [ /Applications/Cocos/frameworks/cocos2d-x-3.6/build/../tests/cpp-tests ] fails!

Sorry for all the self replies, but trial and error have gotten me some progress. If I change the target in cocos/platform/android/java/project.properties (relative to my project root), to android-22 it builds. Is this a bug in 3.6 template?

Had this too - seems to be Eclipse automatically selecting an android build target when importing a project. In my case it was on my google play services lib.

@duckinferno same where.
@Rick_S try go in project properties -> Android then check the proper target name.

Is this problem solved?

Ok,I solved this problem,please use eclipse open this project And click Properties->Android ,then remove the Library and add a new absolute path

If you want another project don’t happen this problem,please modify ?/cocos2dx/cocos/templates/cpp