gpt4 book ai didi

android - ionic 构建安卓错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:40:58 26 4
gpt4 key购买 nike

我是 ionic 框架的新手,我是如何在 Windows 7 系统中启动和运行 cordova 的,但现在我正在尝试使用 ionic 框架构建一个 android 应用程序,我遵循了以下步骤

>npm install -g cordova
>npm install -g ionic
>ionic start resistance blank
>cd resistance
>ionic platform add android

直到这里我都做得很好但是当我运行命令时

>ionic build android

我得到以下错误

    C:\Users\vishwant\resistance>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\vishwant\resistance\hooks\after_prepare\010_add_platform_class.js C:\Users\vishwant\resis
tance
add to body class: platform-android
Running command: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat

C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
Error: ENOENT, no such file or directory 'C:\adt-bundle-windows-x86_64-20140702\sdk\tools\tools\lib\build.template'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:289:15)
at C:\Users\vishwant\resistance\platforms\android\cordova\lib\build.js:120:40
at _fulfilled (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:798:54)
at self.promiseDispatch.done (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:827:30)
at Promise.promise.promiseDispatch (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:760:13)
at C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:574:44
at flush (C:\Users\vishwant\resistance\platforms\android\cordova\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:419:13)
Error: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat: Command failed with exit code 8
at ChildProcess.whenDone (C:\Users\vishwant\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)

我注意到路径不正确,但在我已正确设置的路径变量中,即直到工具。

Error: ENOENT, no such file or directory 'C:\adt-bundle-windows-x86_64-20140702\sdk\tools\tools\lib\build.template'

首先,我不明白为什么它要附加一个工具\并搜索 build.template其次,如果我在 tools\中手动创建那个额外的 tools\文件夹(我想避免),那么上面的错误就消失了,但我会显示

C:\Users\vishwant\resistance>ionic build android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\vishwant\resistance\hooks\after_prepare\010_add_platform_class.js C:\Users\vishwant\resis
tance
add to body class: platform-android
Running command: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat
[Error: Please install Android target "android-19".
Hint: Run "android" from your command-line to open the SDK manager.]
Error: C:\Users\vishwant\resistance\platforms\android\cordova\build.bat: Command failed with exit code 2
at ChildProcess.whenDone (C:\Users\vishwant\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
at Process.ChildProcess._handle.onexit (child_process.js:823:5)

因为我已经安装了 android sdks 和 targets 4.4W,它在 cordova 项目上运行良好,我不明白为什么它在 ionic 框架上失败。

如果我遗漏了什么,请纠正我。

谢谢

最佳答案

我猜是因为你把ANDROID_HOME设置错了路径。

ANDROID_HOME 必须设置到 android SDK 的根目录,而不是 tools 文件夹:

SET ANDROID_HOME=C:\adt-bundle-windows-x86_64-20140702\sdk

但工具文件夹必须在路径中。

SET PATH=%PATH%;%ANDROID_HOME%\tools

(当然是用windows settings来设置env vars,不要用cmd来设置,那只是为了解释的更清楚)

关于android - ionic 构建安卓错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27120950/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com