设置环境变量`ANDROID_NDK_HOME`

4

我正在使用Macbook电脑。我已经下载了Android NDK并将其解压到了电脑上。

~/mytool/android-ndk-r10e

.bash_profile文件中,我已经设置了:
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_NDK_HOME = ~/mytool/android-ndk-r10e

我的项目pom.xml文件中包含以下插件:

<plugin>
   <groupId>com.simpligility.maven.plugins</groupId>
   <artifactId>android-maven-plugin</artifactId>
   <version>4.3.0</version>
   <extensions>true</extensions>
</plugin>

当我运行mvn clean install命令时,我遇到了下面的错误:
[ERROR] Failed to execute goal com.simpligility.maven.plugins:android-maven-plugin:4.3.0:ndk-build (default-ndk-build) on project MyTrackor: No Android NDK path could be found. 

You may configure it in the pom using <ndk><path>...</path></ndk> or <properties><ndk.path>...</ndk.path></properties> or on command-line using -Dandroid.ndk.path=... or by setting environment variable ANDROID_NDK_HOME -> [Help 1]

上述错误提示没有找到Android NDK路径,并建议我设置环境变量ANDROID_NDK_HOME来解决问题。

但是如您所见在我的.bash_profile中,我已经设置了环境变量ANDROID_NDK_HOME。为什么我仍然会遇到这个错误?


你重新加载了你的 bash_profile 吗?尝试强制执行并在终端内执行 export 命令。 - Simon Marquis
1个回答

3

使用命令行验证所有导出变量

export 

如果您没有看到ANDROID_NDK_HOME,这意味着您的bash文件尚未重新加载。接下来:
source .bash_profile to reload the config. 

如果您看到了ANDROID_NDK_HOME,那么问题可能是另外一个。

谢谢,我运行了 export 命令,输出显示了 declare -x ANDROID_NDK_HOME,但是 ANDROID_NDK_HOME 没有值。当我运行 source .bash_profile 命令时,出现了 -bash: export: ~/mytool/android-ndk-r10e: not a valid identifier 的错误提示。这是为什么呢? - Leem.fin
1
很可能是等号两侧的空格引起的问题:export ANDROID_NDK_HOME = ~/mytool/android-ndk-r10e - Zachary Yates

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接