Im using Cordova in Linux mint 17
我在Linux mint 17中使用Cordova。
I installed android sdk , cordova , android studio , nodejs 4
我安装了android sdk、cordova、android studio、nodejs 4
problem is here when i wanna build app in codova and run this on terminal :
问题是当我想在codova建立应用程序并在终端上运行时:
sudo cordova build android
sudo科尔多瓦构建android
it shows
它显示了
Running command: /home/tnt/hello12/platforms/android/cordova/build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /home/tnt/hello12/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/tnt/hello12/platforms/android/cordova/build: Command failed with exit code 2
I put this code
我把这段代码
export HOME="/home/tnt"
export ANDROID_HOME="$HOME/android/sdk/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/android/sdk/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export ANT_HOME="/usr/share/ant"
export PATH="$ANT_HOME/bin:$PATH"
export ANDROID_HOME="/home/tnt/android/sdk/tools"
on my
在我的
/home/tnt/.bash_profile
/home/tnt/.bashrc
/home/tnt/.profile
/root/.bash_profile
/root/.bashrc
/root/.profile
but it wont works
但它不会工作
2 个解决方案
#1
8
I don't think its necessary to add everything into path.Just add the JAVA_HOME
, ANDROID_HOME
and ANT_HOME
to path and point out the corresponding bin directory
as:
我认为没有必要把所有的东西都加进去。只需将JAVA_HOME、ANDROID_HOME和ANT_HOME添加到path中,并指出相应的bin目录如下:
For android studio
add this into your ~/.bashrc
file:
把这个加入你的~中。bashrc文件:(
1.export ANDROID_HOME=/path/to/android/studio
2.export PATH=$PATH:$ANDROID_HOME/bin
you can do the same for Ant.
你也可以为Ant做同样的事情。
For java jdk
add this into your /etc/profile file:
将此添加到/etc/profile文件中:
1.JAVA_HOME=/path/to/jdk
2.JRE_HOME=$JAVA_HOME/jre
3.PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
4.export JAVA_HOME
5.export JRE_HOME
6.export PATH
Now in your terminal, type echo $PATH
and make sure all the environment variables are added to the PATH!
现在在您的终端中,键入echo $PATH,并确保将所有环境变量添加到路径中!
#2
6
You should edit /etc/sudoers with
你应该编辑/etc/sudoers
sudo visudo
At the end of the file enter:
在文件末尾输入:
Defaults env_keep +="ANDROID_HOME"
#1
8
I don't think its necessary to add everything into path.Just add the JAVA_HOME
, ANDROID_HOME
and ANT_HOME
to path and point out the corresponding bin directory
as:
我认为没有必要把所有的东西都加进去。只需将JAVA_HOME、ANDROID_HOME和ANT_HOME添加到path中,并指出相应的bin目录如下:
For android studio
add this into your ~/.bashrc
file:
把这个加入你的~中。bashrc文件:(
1.export ANDROID_HOME=/path/to/android/studio
2.export PATH=$PATH:$ANDROID_HOME/bin
you can do the same for Ant.
你也可以为Ant做同样的事情。
For java jdk
add this into your /etc/profile file:
将此添加到/etc/profile文件中:
1.JAVA_HOME=/path/to/jdk
2.JRE_HOME=$JAVA_HOME/jre
3.PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
4.export JAVA_HOME
5.export JRE_HOME
6.export PATH
Now in your terminal, type echo $PATH
and make sure all the environment variables are added to the PATH!
现在在您的终端中,键入echo $PATH,并确保将所有环境变量添加到路径中!
#2
6
You should edit /etc/sudoers with
你应该编辑/etc/sudoers
sudo visudo
At the end of the file enter:
在文件末尾输入:
Defaults env_keep +="ANDROID_HOME"