Cannot build GoMobile Basic Example for Android

47 Views Asked by At

I pull the repository GoMobile from "https://go.googlesource.com/mobile". Then, I change my directory to C:\repo\GoMobile\example\basic and open "cmd". When I try building the example project for Windows by using

go build

it successfully outputs "basic.exe" and it works perfect as a console application. On the other hand, when I execute "gomobile build" in order to produce apk for android, it first says the following

gomobile build

ANDROID_NDK_HOME specifies C:\Program Files\android-ndk, which is unusable: 
unsupported API version 16 (not in 21..34)

When I do a little search, I hoped the following to be successful:

gomobile build -androidapi 21

gomobile: go build -buildmode=c-shared -o C:\Users\user\AppData\Local\Temp\gomobile-work-1986690211\lib\armeabi-v7a\libbasic.so golang.org/x/mobile/example/basic failed: exit status 1
# runtime/cgo
cgo: C compiler "C:\\Program" not found: exec: "C:\\Program": file does not exist

I have then listed variables using "go env", following variables are present.

set GOVERSION=go1.21.5
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\repo\GoMobile\go.mod

I guess, I have some problems to introduce C compiler path to Gomobile build chain, I am quite new to Go environment. I was expecting a successful ".apk" output just like I get ".exe". What am I missing? Any help would be much appreciated.

0

There are 0 best solutions below