Android Gradle Build Failure - 无法使用哈希字符串'android-22'查找目标

时间:2016-03-24 00:14:22

标签: android android-studio gradle cocos2d-x

我使用Cocos2d-X 3 python命令行工具创建了一个Android Studio,但是我对生成的项目有些麻烦。

每当我打开它或尝试构建它时,我都会收到以下错误:

21:05:01 Gradle sync failed: Cause: failed to find target with hash string 'android-22' in: C:\Desenvolvimento\_Dev_Tools\Android\android-sdk
         Consult IDE log for more details (Help | Show Log)

我已经在互联网上做了一些研究,我发现了几个有关此问题的问题,其中大多数问题的答案是将app \ gradle.build脚本更改为:

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.ArmoniaGames.IgualOuDiferente"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }

这是我的Android SDK配置:

Android SDK Manager

我做错了什么?是否有一些我缺少的配置,可能是Cocos2d-X?

修改

运行android list targets命令的结果:

Available Android targets:
----------
id: 1 or "android-23"
     Name: Android 6.0
     Type: Platform
     API level: 23
     Revision: 2
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in, AndroidWea
rRound, AndroidWearRound360x360, AndroidWearRound400x400, AndroidWearRound480x480, AndroidWearRoundChin320x290, AndroidW
earRoundChin360x325, AndroidWearRoundChin360x330, AndroidWearSquare, AndroidWearSquare320x320, AndroidWearRound, Android
WearRound360x360, AndroidWearRound400x400, AndroidWearRound480x480, AndroidWearRoundChin320x290, AndroidWearRoundChin360
x325, AndroidWearRoundChin360x330, AndroidWearSquare, AndroidWearSquare320x320
 Tag/ABIs : android-tv/armeabi-v7a, android-tv/x86, android-wear/armeabi-v7a, android-wear/x86, default/armeabi-v7a, def
ault/x86, default/x86_64
----------
id: 2 or "Google Inc.:Google APIs:23"
     Name: Google APIs
     Type: Add-On
     Vendor: Google Inc.
     Revision: 1
     Description: Android + Google APIs
     Based on Android 6.0 (API level 23)
     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, AndroidWea
rRound, AndroidWearRound360x360, AndroidWearRound400x400, AndroidWearRound480x480, AndroidWearRoundChin320x290, AndroidW
earRoundChin360x325, AndroidWearRoundChin360x330, AndroidWearSquare, AndroidWearSquare320x320, AndroidWearRound, Android
WearRound360x360, AndroidWearRound400x400, AndroidWearRound480x480, AndroidWearRoundChin320x290, AndroidWearRoundChin360
x325, AndroidWearRoundChin360x330, AndroidWearSquare, AndroidWearSquare320x320
 Tag/ABIs : google_apis/armeabi-v7a, google_apis/x86, google_apis/x86_64

1 个答案:

答案 0 :(得分:0)

它无法找到" android-22" (Lollipop 5.1的SDK)因为你没有安装它。在屏幕截图中,我看到只安装了API级别23。

如果您要构建以定位API 22,则必须安装它并修改您的gradle以匹配

"机器人-22"是等效字符串22.例如compileSdkVersion 22compileSdkVersion "android-22"是等价的。 (目标sdk也一样)

请注意,您可以将compileSdkVersion设置为23,将targetSdkVersion设置为22。