node.js Cordova:您可能没有运行此项目所需的环境或操作系统
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29721410/
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: You may not have the required environment or OS to run this project
提问by strNOcat
On Linux Mint 17.1 x86_64, Cordova v4.3.0 gives this error:
在 Linux Mint 17.1 x86_64 上,Cordova v4.3.0 出现以下错误:
$ cordova run android
Running command: /home/naman/test/platforms/android/cordova/run
WARNING : No target specified, deploying to emulator
WARNING : no emulator specified, defaulting to Sample
Waiting for emulator...
Booting up emulator (this may take a while)....BOOT COMPLETE
/home/naman/test/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error: ENOENT, no such file or directory '/opt/software/android-sdk/tools/tools/lib/build.template'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
at /home/naman/test/platforms/android/cordova/lib/build.js:129:40
at _fulfilled (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:798:54)
at self.promiseDispatch.done (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:827:30)
at Promise.promise.promiseDispatch (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:760:13)
at /home/naman/test/platforms/android/cordova/node_modules/q/q.js:574:44
at flush (/home/naman/test/platforms/android/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
ERROR running one or more of the platforms: Error: /home/naman/test/platforms/android/cordova/run: Command failed with exit code 8
You may not have the required environment or OS to run this project
PATH variable seems to be alright (the path for SDK is correct):
PATH 变量似乎没问题(SDK 的路径是正确的):
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/software/android-sdk/tools:/opt/software/android-sdk/platform-tools
I installed it using :
我使用以下方法安装它:
sudo apt-add-repository ppa:cordova-ubuntu/ppa
sudo apt-get update
sudo apt-get install cordova-cli
npm install -g cordova
The installation went smoothly and the project was created without any error. Am I missing some dependency?
安装顺利,项目创建没有任何错误。我错过了一些依赖吗?
采纳答案by strNOcat
Make sure you have proper environment variables defined (add this in .bash_loginor .profileand do source .profile):
确保您定义了正确的环境变量(在.bash_loginor 中添加.profile并执行source .profile):
export ANDROID_SDK="/opt/software/android-sdk"
export ANDROID_NDK="/opt/software/android-ndk"
export ANDROID_HOME="$ANDROID_SDK"
export ANDROID_PLATFORM_TOOLS="$ANDROID_SDK/platform-tools"
export PATH="${PATH}:$ANDROID_HOME/tools:$ANDROID_PLATFORM_TOOLS"
回答by romixch
You may need to uninstall the existing app on your device.
您可能需要卸载设备上的现有应用程序。
I installed my app on that device from another computer. When I run cordova run androidI get
我从另一台计算机在该设备上安装了我的应用程序。当我跑步时,cordova run android我得到
You may not have the required environment or OS to run this project.
You may not have the required environment or OS to run this project.
But when I try to install my apk by adbit told my that the app was already installed. So I uninstalled it an it worked.
但是当我尝试安装我的 apk 时,adb它告诉我该应用程序已经安装。所以我卸载了它,它起作用了。
回答by brendan
For others having this problem, assuming you have already checked and fixed any environment variables using @Naman Dixit's answer, you may also have to remove and add your platforms:
对于其他遇到此问题的人,假设您已经使用@Naman Dixit 的回答检查并修复了任何环境变量,您可能还需要删除并添加您的平台:
cmd: cordova platform rm [platform(s) of interest]
delete everything in the [yourproject]/platforms folder. Then:
删除 [yourproject]/platforms 文件夹中的所有内容。然后:
cmd: cordova platform add [platform(s) of interest]
that was the final step I needed to get everything to work
这是我让一切正常工作所需的最后一步
回答by TchiYuan
Your android sdk doesn't seem to be properly installed or you didn't install the proper android sdk version that has the dependency that you seem to be missing
您的 android sdk 似乎没有正确安装,或者您没有安装正确的 android sdk 版本,该版本具有您似乎缺少的依赖项
/opt/software/android-sdk/tools/tools/lib/build.template
回答by fedmich
I encountered this issue now too. The problem in my case is that the ant.properties file that I'm using is pointed to wrong and NOT existing file.
我现在也遇到了这个问题。我的问题是我使用的 ant.properties 文件指向错误而不是现有文件。
key.store=D:/Fedmich/_keys/android.keystore
After correcting it, I was able to compile a release apk. Hope this helps someone in the future. Just be sure to read the error_logs that is given in the command prompt.
更正后,我能够编译发布 apk。希望这对将来的人有所帮助。请务必阅读命令提示符中给出的 error_logs。
回答by YoungHyeong Ryu
I got a same error my solution is underlying.
我遇到了同样的错误,我的解决方案是潜在的。
- command adb device no result.....
- install usb drive for mobile (my phone is lg g3)
- 命令 adb device 没有结果.....
- 为手机安装 USB 驱动器(我的手机是 lg g3)
reeboot and command adb device again : result device showing. then tried again 3. ionic run adnroid --device "OK";
reeboot 并再次命令 adb device :结果设备显示。然后再试一次 3. ionic run adnroid --device "OK";
回答by Kishor Pawar
This is just to have one more reason for this error documented here and for them who are still searching for solution.
这只是为了在此处记录此错误以及为仍在寻找解决方案的他们提供另一个原因。
When I came accross this error, I tried almost all the solutions listed on the stackoverflow.
当我遇到这个错误时,我尝试了stackoverflow.
My issue was my device was not getting detected by adb, adb kill-server/start-serveralso not helped me, ***
我的问题是我的设备没有被检测到adb,adb kill-server/start-server也没有帮助我,***
but changing
USBport helped.
但改变
USB端口有帮助。
回答by kentrh
I got this error after installing the Crosswalk plugin. To solve it I installed the latest Android SDK, deleted the android folder under platforms and ran
安装Crosswalk 插件后出现此错误。为了解决它我安装了最新的Android SDK,删除了平台下的android文件夹并运行
phonegap build android
phonegap build android
alternatively
或者
cordova platform add --save android
cordova platform add --save android
cordova build android
cordova build android
and it was all good.
一切都很好。
回答by malrok44
I had the same error building the android platform, and no solution given here could help me. I decided to run the gradlew command shown by cordova, and saw there was a problem with a png file included in the cordova project. After removing it, I managed building the platform again.
我在构建 android 平台时遇到了同样的错误,这里给出的任何解决方案都无法帮助我。我决定运行cordova 显示的gradlew 命令,发现cordova 项目中包含的png 文件存在问题。删除它后,我再次设法构建了平台。
回答by Pablo Cegarra
export ANDROID_HOME=/Applications/adt-bundle-mac-x86_64-20140321/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
then cordova run android works
然后cordova运行android作品

