Cannot compile project for Android (not a valid android target platform.)

I’m trying to compile my project for Android, but i get an error

$ cocos compile -p Android -s MyProject
Running command: compile
Building mode: debug
GoogleInc.:GoogleAPIs:21 is not a valid android target platform.

I’ve dowloaded and installed all dependencies

  1. Apache Ant

    $ ant -v
    Apache Ant™ version 1.9.3 compiled on April 8 2014
    Trying the default build file: build.xml
    Buildfile: build.xml does not exist!
    Build failed

  2. android-ndk-r10e

  3. Android SDK

Why i’m getting error ? How to solve it

Maybe you will need to give us more information but, compile for android you need Android NDK if you use android NDK10+ you will need to target android -19 not Google API 19.

$ android list targets
Available Android targets:
----------
id: 1 or "android-21"
     Name: Android 5.0.1
     Type: Platform
     API level: 21
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
 Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, android-wear/armeabi-v7a, android-wear/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 2 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, AndroidWearRound, AndroidWearRound400x400, AndroidWearRoundChin320x290, AndroidWearSquare, AndroidWearSquare320x320, AndroidWearRound, AndroidWearRound400x400, AndroidWearRoundChin320x290, AndroidWearSquare, AndroidWearSquare320x320
 Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, android-wear/armeabi-v7a, android-wear/x86, default/armeabi-v7a, default/x86, default/x86_64
----------
id: 3 or "android-MNC"
     Name: Android M (Preview)
     Type: Platform
     API level: MNC
     Revision: 1
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : android-tv/x86, default/arm64-v8a, default/armeabi-v7a, default/mips, default/x86
----------
id: 4 or "Google Inc.:Google APIs:21"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 5.0.1 (API level 21)
     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, AndroidWearRound, AndroidWearSquare, AndroidWearRound, AndroidWearSquare
 Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64
----------
id: 5 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, AndroidWearRound, AndroidWearRound400x400, AndroidWearRoundChin320x290, AndroidWearSquare, AndroidWearSquare320x320, AndroidWearRound, AndroidWearRound400x400, AndroidWearRoundChin320x290, AndroidWearSquare, AndroidWearSquare320x320
 Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64

How should i compile ?

hi @maxiannicu

Have you installed all the android sdk (api 21) ?
if yes, then check for the ndk version.
may be r10e is not compatible, but I know r10c will work just fine :smile:

Is that ok ?

In project.properties you can see (but not set) the target API.
I have had issues with using ‘Google Inc.:Google APIs:n’ in the past.

i.e.
I target 13, so this will NOT work for me right now with Cocos2d-x 3.7:
target=Google Inc.:Google APIs:13

But this will work:
target=android-13

To chose the target in Eclipse, right click on your project and choose Properties->Andorid and then select the non Google Inc API.

Not sure why using the Google Inc. version of the API doesn’t work.

On a side note, I get Google Play Services, IAP and Admob all from the google-play-services_lib, so not sure why I would need the Google Inc. API version.