离子模拟Ionic2中的android错误

时间:2016-08-30 13:34:28

标签: android ionic-framework ionic2

我正在使用Ionic2,当我尝试ionic emulate android时,我在终端中收到此错误:

BUILD FAILED

Total time: 8.651 secs

Error: /home/xxxx/Desktop/myCoolApp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> failed to find target with hash string 'android-23' in: /home/xxxx/Android/Sdk

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Please install Android target: "android-23".

Hint: Open the SDK manager by running: /home/xxxx/Android/Sdk/tools/android
You will require:
1. "SDK Platform" for android-23
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)

platforms/android/gradle/project.properties文件中(在我的ionic2项目文件夹下)我有target=android-23

platforms/android/gradle/AndroidManifest.xml文件的最后一行,我有<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />

这是我的SDK_Manager: enter image description here

也许如果我从Android 24降级到Android 23它会起作用(没试过),但我不认为这是解决这个问题的正确方法。

所以我尝试用这种方式更改前两个文件:

In `platforms/android/gradle/project.properties` file (under my ionic2 project folder) I set `target=android-24`.
In the last line of `platforms/android/gradle/AndroidManifest` file I set `<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="24" />`.

但是我仍然遇到同样的错误,我错过了什么?

供参考:

android list targets给了我这个:

Available Android targets:
----------
id: 1 or "android-24"
     Name: Android 7.0
     Type: Platform
     API level: 24
     Revision: 1
     Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7in
 Tag/ABIs : no ABIs.

提前致谢

1 个答案:

答案 0 :(得分:0)

解决。

除了platforms/android/gradle/AndroidManifest.xmlplatforms/android/gradle/project.properties之外,我还必须将target=android-23更改为target=android-24内的platforms/android/CordovaLib/project.properties