Cordova平台添加android错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20897115/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cordova platform add android error
提问by Derek
Using ubuntu 12.04
使用 Ubuntu 12.04
cordova platform add android
Creating android project...
/usr/local/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/admin/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/home/admin/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
at /usr/local/lib/node_modules/cordova/src/platform.js:244:30
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
What am I doing wrong?
我究竟做错了什么?
回答by jloubert
I was having what looks like the same problem. Make sure you add the ADT tools and platform-tools to your system path; doing this fixed the problem for me. Go to your .bashrc file (in your home directory) and add something like:
我遇到了同样的问题。确保将 ADT 工具和平台工具添加到系统路径中;这样做为我解决了问题。转到您的 .bashrc 文件(在您的主目录中)并添加如下内容:
export PATH=${PATH}:/your-path/android-sdk-linux/platform-tools:/your-path/android-sdk-linux/tools
Then restart your session or do $ source .bashrc
to enable the changes. Now cordova should be able to create the Android project just fine.
然后重新启动您的会话或执行$ source .bashrc
以启用更改。现在cordova 应该可以很好地创建Android 项目了。
回答by KrIsHnA
Simple as download sdk, extract somewhere, export that path, do source to take effect, then continue... :)
简单的下载sdk,解压到某处,导出那个路径,做源码生效,然后继续... :)
sudo gedit ~/.bashrc
须藤 gedit ~/.bashrc
add "PATH=$PATH:/opt/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/opt/adt-bundle-linux-x86_64-20140321/sdk/tools" to the bottom.
添加“ PATH=$PATH:/opt/adt-bundle-linux-x86_64-20140321/sdk/platform-tools:/opt/adt-bundle-linux-x86_64-20140321/sdk/tools”到底部。
make sure your path specified is correct., adt-bundle-linux-x86_64-20140321changes according to the version you download.
请确保您指定的路径正确。adt-bundle-linux-x86_64-20140321根据您下载的版本而变化。
source ~/.bashrc
源 ~/.bashrc
to take path in to current session.
进入当前会话的路径。
then from your build directory (mine is ~/phoneGapBuild/hello ).
然后从你的构建目录(我的是 ~/phoneGapBuild/hello )。
cordova platform add android
科尔多瓦平台添加android
(@) To see current path variables:
(@) 查看当前路径变量:
echo $PATH(If you don't see newly added variables, please exit terminal and open it again)
echo $PATH(如果没有看到新添加的变量,请退出终端再打开)
(@) If you got an error like
(@) 如果你有这样的错误
Error: ERROR : executing command 'ant', make sure you have ant installed and added to your path.
错误:错误:正在执行命令“ant”,请确保您已安装 ant 并将其添加到您的路径中。
run the following comment to install ant. sudo apt-get -u install ant
运行以下注释来安装 ant。 sudo apt-get -u 安装蚂蚁
回答by codarrior
For windows edit the PATH variable from Control Panel > System > Advanced system settings > Environment Variables. Add the path to Android SDK's platform-tools and tools folder. For me it was C:\Users\\MyPersonalStuffs\Software\adt-bundle-windows-x86_64-20140321\sdk\platform-toolsand C:\Users\\MyPersonalStuffs\Software\adt-bundle-windows-x86_64-20140321\sdk\toolslocation. Then make sure you open a new terminal tool for the PATH to take effect. Also make sure that you have antavailable in the path as well.
对于 Windows,从 Control Panel > System > Advanced system settings > Environment Variables编辑 PATH变量。将路径添加到 Android SDK 的 platform-tools 和 tools 文件夹。对我来说是C:\Users\\MyPersonalStuffs\Software\adt-bundle-windows-x86_64-20140321\sdk\platform-tools和C:\Users\\MyPersonalStuffs\Software\adt-bundle-windows-x86_64-20140321\ sdk\工具位置。然后确保您打开了一个新的终端工具以使 PATH 生效。还要确保您在路径中也有蚂蚁。
回答by Jogosb
I had the same problem today on my Windows7. My colleague send me an Ionic project and I couldn't run it on my device. Finally I removed platforms folder which was created by him and I add it myself using:
我今天在 Windows7 上遇到了同样的问题。我的同事给我发了一个 Ionic 项目,但我无法在我的设备上运行它。最后,我删除了他创建的平台文件夹,并使用以下方法自行添加:
ionic platform add android
离子平台添加android
and then it run normally after ionic run android
然后它在ionic run android之后正常运行
Hope it helps sb.
希望对某人有帮助。
回答by Tushar kumar
fix is here(FOR WINDOWS ONLY)
修复在这里(仅适用于 WINDOWS)
I am facing the same problem of Build then i finally found out the solution.
我面临着同样的构建问题,然后我终于找到了解决方案。
SOLUTION
So You must have the Android Api 23 in order for this command to work.
Error of Daemon process will be solve after installing the Api 23 and extra
build tools and run command
COMMAND : cordova build android --release
I am sure this fix would help you to solve the problem.
解决方案
因此,您必须拥有 Android Api 23 才能运行此命令。
安装 Api 23 和额外的
构建工具并运行命令
COMMAND后,守护进程的错误将得到解决:cordova build android --release
我相信此修复程序将帮助您解决问题。
STEPS
1. First check the version of android through this COMMAND:
cordova platform help
2. Run the build command after installing the Api 23 and extra build tools.
3. If Even this not work then Try add the variable in the
Environment variables > System variables >
add _JAVA_OPTIONS and value = -Xmx512M
STEPS
1.首先通过这个命令检查android的版本:cordova platform help
2.安装Api 23和额外的构建工具后运行构建命令。
3.如果即使这不起作用,请尝试在
环境变量>系统变量>
添加_JAVA_OPTIONS和值= -Xmx512M中添加变量
Then Run cordova build android --release
然后运行 cordova build android --release
BUT FIRSTLY SET UP THE ENVIRONMENT VARIABLES Environment Variable setup Image
但首先设置环境变量 环境变量设置图像
COPY FROM HERE
ENVIRONMENT VARIABLES:-
从这里复制
环境变量:-
USER VARIABLES
PATH
C:\Ruby23\bin;C:\Users\kumar\AppData\Roaming\npm;C:\ANDROID_SDK\tools;%SystemRo ot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;SYSTEM VARIABLES
ADD NAME AND VALUE
2.1 _JAVA_OPTIONS-Xmx512M
2.2 ANDROID_HOMEC:\ANDROID_SDK
2.3 PATH->
C:\ProgramFiles\Java\jdk1.8.0_60\bin;C:\ProgramFiles\nodejs;C:\Gradle\gradle-4.0\bin;C:\ANDROID_SDK\tools;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
用户变量
路径
C:\Ruby23\bin;C:\Users\kumar\AppData\Roaming\npm;C:\ANDROID_SDK\tools;%SystemRo ot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;系统变量
添加名称和值
2.1 _JAVA_OPTIONS-Xmx512M
2.2 ANDROID_HOMEC:\ANDROID_SDK
2.3 PATH->
C:\ProgramFiles\Java\jdk1.8.0_60\bin;C:\ProgramFiles\nodejs\C:\Gradle bin;C:\ANDROID_SDK\tools;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;