尝试安装离子,当添加android平台时,我收到以下错误
Error: Please install Android target "android-19".
Hint: Run "android" from your command-line to open the SDK manager.
at /home/algotree/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/lib/check_reqs.js:174:19
at _fulfilled (/home/algotree/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/algotree/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/algotree/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:760:13)
at /home/algotree/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:574:44
at flush (/home/algotree/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: /home/algotree/.cordova/lib/npm_cache/cordova-android/3.6.4/package/bin/create: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
但我已经安装了android-21。如何在不安装target-19的情况下使用它?
答案 0 :(得分:10)
这是因为在运行命令ionic create myApp.
此脚本位于cordova目录中 - C:\Users\[user]\.cordova\lib\npm_cache\cordova-android\3.6.4\package\framework\project.properties
(适用于Windows)。
当您进入project.properties
文件时,您会看到与下面类似的内容。
split.density =假
目标=机器人-19
APK的配置=
renderscript.opt.level = O0
- 醇>
android.library =真
您需要修改target=android-19
行,target=android-21
希望这会有所帮助,因为我对Ionic和混合移动开发都很陌生,但我记得读过几个有同样问题的人。我自己遇到了这个错误,虽然我没有安装android-19修复它的问题。
通过在android list target
内运行C:\Users\[user]
,您可以在文件资源管理器中浏览每个目录来检查可用目标的另一种方法。
答案 1 :(得分:3)
找到项目根目录[project_root]/platforms/android/project.properties
中的文件夹,并将目标替换为您的首选
target=android-21
android.library.reference.1=CordovaLib