I am a learner of golang ,trying to use golang to develop android When I want to package into APK, I encounter the following problems

I'm following the official guide to install gomobile. OS:Win10 go version go1.20.2 windows/amd64

I have installed Android Studio and SDK Tools(NDK)

I have set patch

ANDROID_HOME // C:\Users\AI007\AppData\Local\Android\Sdk

ANDROID_NDK_HOME // C:\Users\AI007\AppData\Local\Android\Sdk\ndk\25.2.9519653

When I want to package into APK, I encounter the following problems

input command

C:\Users\AI007>gomobile bind -target=android goapp

show

gomobile: ANDROID_NDK_HOME specifies C:\Users\AI007\AppData\Local\Android\Sdk\ndk\25.2.9519653, which is unusable: unsupported API version 16 (not in 19..33)

Google has found a lot of methods, how to solve this problem, it has troubled me for several days, thank you

2

There are 2 best solutions below

0
On

you should add androidapi {latest android api version}" to your gomobile command.

You command will currently be:

gomobile bind -target=android -androidapi 21 goapp
0
On

ok I now its a little late but I found the solution for this and that was downloading the Unsupported NDK from the link down below and copy the package to the \AppData\Local\Android\Sdk\ndk directory along side with other versions of NDK. I also updated the ANDROID_NDK_HOME with the new directory.

https://github.com/android/ndk/wiki/Unsupported-Downloads

the version that worked for me was android-ndk-r20b-windows-x86_64.zip.

also as the blog says : Note: these obsolete versions of the NDK are no longer supported. Use a current release instead.