【问题标题】:no Android NDK found in $ANDROID_HOME/ndk-bundle nor in $ANDROID_NDK_HOME in Windows 10在 Windows 10 的 $ANDROID_HOME/ndk-bundle 和 $ANDROID_NDK_HOME 中找不到 Android NDK
【发布时间】:2021-07-18 10:41:51
【问题描述】:

我正在关注official guide 安装gomobile。我安装了 Android Studio 并通过 Android Studio SDK 管理安装的NDK (side by side) 和所有 SDK 包。 Android Studio 在我的设备上编译和部署我的普通 Android 应用程序没有问题。

我运行成功(我的意思是没有任何错误):

go env -w GO111MODULE=auto

gomobile init

go get -d golang.org/x/mobile/example/basic

然后我跑了:

gomobile build -target=android golang.org/x/mobile/example/basic

得到了错误:

gomobile: no Android NDK found in $ANDROID_HOME/ndk-bundle nor in $ANDROID_NDK_HOME

当我按照answer 中的建议运行到另一个旧线程时:

gomobile init -ndk C:\Users\Christian\AppData\Local\Android\Sdk\ndk-bundle

我明白了:

flag provided but not defined: -ndk
usage: gomobile init [-openal dir]

我需要做什么来解决这个问题?

【问题讨论】:

  • 你在环境系统变量中添加路径了吗?

标签: go android-ndk gomobile gomobile-android


【解决方案1】:

linux/mac 用户解决方案

我在 Linux 上遇到了同样的问题,我通过这样设置环境变量解决了这个问题:

export ANDROID_HOME=$HOME/Android/Sdk

在此路径中,我有 ndk-bundle 文件夹,也可以是 downloaded from here

之后我可以简单地运行

gomobile bind -x -v .

在我的项目目录中,我得到了我想要的 .aar 文件。

【讨论】:

  • 这个问题是关于Windows 10的:'export' is not recognized as an internal or external command, operable program or batch file.
  • 我错过了,谢谢。我更改了答案,因此它似乎针对 linux/mac 用户。
猜你喜欢
  • 1970-01-01
  • 2018-01-12
  • 2014-04-10
  • 2019-06-11
  • 2021-11-18
  • 2021-01-29
  • 2012-09-11
  • 2014-05-30
  • 2021-11-26
相关资源
最近更新 更多