我在
Linux中使用Cordova薄荷17
我安装了android sdk,cordova,android studio,nodejs 4
问题在这里
当我想在codova中构建应用程序并在终端上运行它时:
sudo cordova构建android
表明
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
我把这段代码
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"
在我的
/home/tnt/.bash_profile /home/tnt/.bashrc /home/tnt/.profile /root/.bash_profile /root/.bashrc /root/.profile
但它不工作
解决方法
我不认为有必要将所有内容添加到路径中.只需将JAVA_HOME,ANDROID_HOME和ANT_HOME添加到路径中,并将相应的bin目录指向为:
对于android工作室
1.export ANDROID_HOME=/path/to/android/studio 2.export PATH=$PATH:$ANDROID_HOME/bin
你可以为蚂蚁做同样的事情.
对于java jdk
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
现在在您的终端中,键入echo $PATH,并确保将所有环境变量添加到PATH!