gpt4 book ai didi

java - Cordova 找不到 $ANDROID_HOME

转载 作者:太空宇宙 更新时间:2023-11-04 11:45:24 27 4
gpt4 key购买 nike

我找到了很多解决方案,但它们都没有帮助我。

我在/home/username/.zshrc中定义了变量

export ANDROID_HOME="/home/username/Android/Sdk"
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

定义变量是因为:

echo $ANDROID_HOME                -> /home/username/Android/Sdk
echo $ANDROID_HOME/tools -> /home/zemil/Android/Sdk/tools
echo $ANDROID_HOME/platform-tools -> /home/zemil/Android/Sdk/platform-tools

下面的命令也可以正常工作:

> ionic cordova requirements

Requirements check results for android:
Java JDK: installed 1.8.0
Android SDK: installed true
Android target: installed android-29,android-28
Gradle: installed /usr/share/java/gradle/bin/gradle

我尝试构建一个项目

> sudo ionic cordova build --release android --verbose

...
Prepared android project successfully
No scripts found for hook "after_prepare".
No scripts found for hook "before_compile".
CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting it manually.
Detected 'adb' command at /usr/bin but no 'platform-tools' directory found near.
Try reinstall Android SDK or update your PATH to include valid path to SDK/platform-tools directory.

最佳答案

为我的 linux 尝试了很多带有 env 变量的文件

在 manjaro linux 中,它只需要在文件中写入环境变量:

/etc/environment

export ANDROID_HOME="/home/{USER_NAME}/Android/Sdk"
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

所以 cordova 在这种情况下效果很好

Change USER_NAME to your linux user name

Also should refresh paths ($ source ./environment) or restart system

关于java - Cordova 找不到 $ANDROID_HOME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57935952/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com