Cordova 运行 android:ANDROID_HOME 未设置且 android 不在我的路径中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26033128/
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 run android : ANDROID_HOME not set and android not in my path
提问by Sorcim
When i run for android, i see this error :
当我为 android 运行时,我看到这个错误:
ERROR: Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.
But this "variable" are ok. "Android" launch SDK manager and ANDROID_HOME redirect to my sdk folder.
但是这个“变量”是可以的。“Android”启动 SDK 管理器和 ANDROID_HOME 重定向到我的 sdk 文件夹。
I don't understand this error.
我不明白这个错误。
FYI my export :
仅供参考我的出口:
export ANDROID_HOME=`brew --prefix android`
export PATH=${PATH}:$ANDROID_HOME/bin
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
采纳答案by Sorcim
I answer me !
我回答我!
My solution :
我的解决方案:
sudo chown -R your-user /usr/local/lib/node_modules/cordova
须藤 chown -R 你的用户 /usr/local/lib/node_modules/cordova
Remove and add platform
删除和添加平台
回答by gilcierweb
Ubuntu 14.04 gedit /root/.bashrc add line
Ubuntu 14.04 gedit /root/.bashrc 添加行
export JAVA_HOME=/usr/lib/jvm/java-8-oracle/
ANDROID_HOME=/root/android/sdk/
export ANDROID_HOME=$ANDROID_HOME
PATH=$PATH:$ANDROID_HOME/tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/build-tools
IN TERMINAL source ~/.bashrc
在终端源 ~/.bashrc
Resolveu pra mim/Solved for me!
Resolveu pra mim/为我解决了!
回答by Mark Rossiter
Took me longer than I care to admit to solve this problem, so I thought I'd share how I got this working on Mac for the more novice users such as myself and also those who have not installed with Homebrew:
我花了比我愿意承认的更长的时间来解决这个问题,所以我想我会分享我如何在 Mac 上为更多的新手用户(例如我自己以及那些没有安装 Homebrew 的用户)进行这项工作:
1) Open your bash profile file (the path to finding this file is 'User/.bash_profile', the name of your file may be .profile or something similar).
1) 打开你的 bash 配置文件(找到这个文件的路径是“用户/.bash_profile”,你的文件名可能是 .profile 或类似的东西)。
2) Add a path to wherever you have saved the Android SDK (you may add something like this: 'export PATH=${PATH}:/Applications/adt-bundle/sdk/platform-tools:/Applications/adt-bundle/sdk/tools' or you may add something like this: 'export PATH=${PATH}:/Desktop/adt-bundle/sdk/platform-tools:/Desktop/adt-bundle/sdk/tools').
2) 添加保存 Android SDK 的路径(您可以添加如下内容:'export PATH=${PATH}:/Applications/adt-bundle/sdk/platform-tools:/Applications/adt-bundle/ sdk/tools' 或者您可以添加如下内容:'export PATH=${PATH}:/Desktop/adt-bundle/sdk/platform-tools:/Desktop/adt-bundle/sdk/tools')。
Make sure the file name 'adt-bundle' shown in the path above is the name you have saved for the folder! If it isn't, either save the folder with this name, or alter the path to reflect what you have saved the folder as.
确保上面路径中显示的文件名“adt-bundle”是您为文件夹保存的名称!如果不是,请使用此名称保存文件夹,或更改路径以反映您保存文件夹的内容。
3) Try again. You might encounter some further errors, I resolved mine by visiting this page: Cordova 3.5.0 Install Error- Please Install Android Target 19I typed 'Android' in the terminal to head straight to the package manager in Eclipse. After installing the required version the command worked and installed the Android package to my Cordova application.
3) 再试一次。您可能会遇到一些其他错误,我通过访问此页面解决了我的错误:Cordova 3.5.0 安装错误-请安装 Android Target 19我在终端中输入“Android”以直接前往 Eclipse 中的包管理器。安装所需版本后,该命令运行并将 Android 包安装到我的 Cordova 应用程序中。
I found the following pages very helpful in coming to the above conclusions:
我发现以下页面对得出上述结论非常有帮助:
-Understanding the path (needed a refresher on using path! Last time I had to bother with this was ages ago when installing the rbenv Ruby environment): http://help.exercism.io/understanding-path.html
- 了解路径(需要复习使用路径!上次我在安装 rbenv Ruby 环境时不得不为此烦恼是在很久以前):http://help.exercism.io/understanding-path.html
-Setting up for Android (where I found the path): http://docs.phonegap.com/en/edge/guide_platforms_android_index.md.html#Using%20Plugman%20to%20Manage%0APlugins
- 为 Android 设置(我找到了路径):http: //docs.phonegap.com/en/edge/guide_platforms_android_index.md.html#Using%20Plugman%20to%20Manage%0APlugins
No 'sudo' required.
不需要“sudo”。
回答by Helder Robalo
When my environment is OK (which means that running 'android' via CLI will open the android sdk manager), but I still get this error...
当我的环境正常时(这意味着通过 CLI 运行“android”将打开 android sdk 管理器),但我仍然收到此错误...
I do the follow:
我执行以下操作:
1 - Remove the platform Android from your project cordova platform remove android
2 - Then I just run again phonegap run android
(it'll add the platform Android automatically)
1 - 从您的项目中删除平台 Android cordova platform remove android
2 - 然后我再次运行phonegap run android
(它会自动添加平台 Android)
回答by maudulus
I had to close and re-open my windows console (or open a new console), and then open the SDK manager (ran android), after which a bunch of updates and installs had to complete.
我不得不关闭并重新打开我的 Windows 控制台(或打开一个新控制台),然后打开 SDK 管理器(运行 android),之后必须完成一系列更新和安装。
回答by Naushad Qamar
For me following steps work :
对我来说,以下步骤有效:
sudo chown -R your-user /usr/local/lib/node_modules/cordova
须藤 chown -R 你的用户 /usr/local/lib/node_modules/cordova
export PATH=$PATH:/users/your-user/android-sdks/tools
导出 PATH=$PATH:/users/your-user/android-sdks/tools
and then update your android if it is not updated to latest version.
如果没有更新到最新版本,然后更新您的android。
http://blog.codersight.com/2015/05/error-androidhome-is-not-set-and.html
http://blog.codersight.com/2015/05/error-androidhome-is-not-set-and.html
回答by Leo
For anybody like me who has tried everything in the answers and have all the environmental variables set up but still gets an error. You might need to remove and add the android platform to your project with the cordova CLI.
对于像我这样尝试了所有答案并设置了所有环境变量但仍然出现错误的人。您可能需要使用cordova CLI 删除android 平台并将其添加到您的项目中。
cordova platform rm android
cordova platform add android