Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/mobile/cmd/gomobile: init subcommand doesn't suppport -androidapi flag #58661

Open
zergon321 opened this issue Feb 23, 2023 · 5 comments
Open
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@zergon321
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.20.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zergon321/.cache/go-build"
GOENV="/home/zergon321/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zergon321/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zergon321/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build824783065=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I installed golang.org/x/mobile and latest Android SDK and NDK via Android Studio. Then I downloaded the openal-soft source code. After this I ran:

ANDROID_PLATFORM=android-25 ANDROID_HOME=~/Android/Sdk/ ANDROID_NDK_HOME=~/Android/Sdk/ndk/25.2.9519653/ gomobile init -openal ~/cpp/openal-soft/

What did you expect to see?

I expected the command to build OpenAL for Android so it could be used with gomobile build
and gomobile install.

What did you see instead?

gomobile: ANDROID_NDK_HOME specifies /home/zergon321/Android/Sdk/ndk/25.2.9519653/, which is unusable: unsupported API version 16 (not in 19..33)
@thanm thanm added WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Feb 23, 2023
@thanm
Copy link
Contributor

thanm commented Feb 23, 2023

When I look at https://developer.android.com/ndk/downloads/revision_history, it looks pretty clear that the version of the NDK you are using (24) only supports API level 19 and above:

Jelly Bean (APIs 16, 17, and 18) is no longer supported. The minimum OS supported by the NDK is KitKat (API level 19).

So what you are seeing looks like expected behavior. Suggest you select a different android API level with the proper flag, e.g. https://cs.opensource.google/go/x/mobile/+/master:cmd/gomobile/build.go;l=63;drc=43a0384520996c8376bfb8637390f12b44773e65

@zergon321
Copy link
Author

But the gomobile init command does not support the -androidapi flag.

$ ANDROID_HOME=~/Android/Sdk/ ANDROID_NDK_HOME=~/Android/Sdk/ndk/25.2.9519653/ gomobile init -androidapi 25 -openal ~/cpp/openal-soft/

Gives the output:

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

If a OpenAL source directory is specified with -openal, init will
build an Android version of OpenAL for use with gomobile build
and gomobile install.

So what should I do exactly?

@thanm thanm removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 23, 2023
@thanm
Copy link
Contributor

thanm commented Feb 23, 2023

I see. This does seem like a problem.

@hyangah do you have any insights here? Perhaps minAndroidAPI needs to be bumped?

@bcmills bcmills added the mobile Android, iOS, and x/mobile label Feb 23, 2023
@bcmills
Copy link
Contributor

bcmills commented Feb 23, 2023

(CC @golang/android)

@seankhliao seankhliao changed the title affected/package: x/mobile x/mobile/cmd/gomobile: init subcommand doesn't suppport -androidapi flag Feb 24, 2023
@gopherbot gopherbot added this to the Unreleased milestone Feb 24, 2023
@fischman
Copy link

Possibly https://cs.opensource.google/go/x/mobile/+/master:internal/binres/binres.go;drc=8578da9835fd365e78a6e63048c103b27a53a82c;l=253 is to blame.

Build succeeds: gomobile build -target=android -androidapi 29 golang.org/x/mobile/example/basic
But install fails: gomobile install -target=android -androidapi 29 golang.org/x/mobile/example/basic with:

adb: failed to install basic.apk: Failure [INSTALL_FAILED_DEPRECATED_SDK_VERSION: App package must target at least SDK version 23, but found 16]

Inspecting the built basic.apk with apktool d basic.apk reveals in ndroidManifest.xml: platformBuildVersionCode="16" (and no other API version mention).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mobile Android, iOS, and x/mobile NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants