cordova错误:请安装Android目标:“android-22”(当我已经有23个)

时间:2015-09-17 05:15:28

标签: android cordova

当我制作我的第一个hello world app时,Cordova给了我这个错误。

我打字:

cordova build android

我得到了以下输出:

[Error: Please install Android target: "android-22".

Hint: Open the SDK manager by running: /home/nicki/Android/Sdk/tools/android
You will require:
1. "SDK Platform" for android-22
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)]
ERROR building one of the platforms: Error: /home/nicki/code/cordova/hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/nicki/code/cordova/hello/platforms/android/cordova/build: Command failed with exit code 2
    at ChildProcess.whenDone (/usr/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:766:16)
    at Process.ChildProcess._handle.onexit (child_process.js:833:5)

我使用的是Ubuntu 14.04。

我的应用中的Android Manifest文件:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.example.hello" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />
</manifest>

我还将<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="22" />修改为

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />

并且它仍然给出了android-22的相同错误(即使它在文件中是19)。 除此之外,我得到23甚至比22好,你可以在我的截图中看到: enter image description here

4 个答案:

答案 0 :(得分:1)

这可能是您正在使用的Cordova版本的问题。每个版本的cordova都只支持一套Android版本。请阅读此内容以获取更多信息:https://cordova.apache.org/announcements/2015/07/21/cordova-android-4.1.0.html

答案 1 :(得分:1)

只需将下面列出的文件编辑为

即可
# Project target.
target=android-23
  • 对myApp /平台/机器人/ project.properties
  • 对myApp /平台/机器人/ CordovaLib / project.properties

从屏幕截图中我了解到,您已在版本23中安装了Android SDK Platform toolAndroid SDK Build tool。因此,您必须在上述文件中更改项目目标。

它对我有用。感谢

答案 2 :(得分:0)

我在Windows 7 x64上。 对我来说,问题是默认的java.exe是从Oracle的JDK 8u40(在PATH上)运行的,而我的JAVA_HOME是在指向使用WAS 8.5的IBM(WebSphere)JDK

我跑完后

set JAVA_HOME=c:\devtools\jdk_8u40 

在我的shell中,它指向Oracle的JDK目录,它终于开始工作了!

答案 3 :(得分:0)

这对我有用,我的特定方法是:从path的环境变量中删除对oracle目录的引用,并将JDK版本减少到1.8.0u65