From 5c0c084b6e9d603a6b01056f5f0426a16b9857e1 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 27 Mar 2024 13:56:00 +0900 Subject: [PATCH] cmd/ebitenmobile: update the default Android SDK version to 21 --- cmd/ebitenmobile/main.go | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cmd/ebitenmobile/main.go b/cmd/ebitenmobile/main.go index 61facba9f..9701d1938 100644 --- a/cmd/ebitenmobile/main.go +++ b/cmd/ebitenmobile/main.go @@ -54,11 +54,6 @@ func goEnv(name string) string { return strings.TrimSpace(string(val)) } -const ( - // Copied from gomobile. - minAndroidAPI = 15 -) - var ( buildA bool // -a buildI bool // -i @@ -99,6 +94,11 @@ func main() { flag.Usage() } + // minAndroidAPI specifies the minimum API version for Android. + // Now Google Player v23.30.99+ drops the API level that is older than 21. + // See https://apilevels.com/. + const minAndroidAPI = 21 + var flagset flag.FlagSet flagset.StringVar(&buildO, "o", "", "") flagset.StringVar(&buildGcflags, "gcflags", "", "") @@ -150,6 +150,20 @@ func main() { log.Fatal(err) } + // If args doesn't include '-androidapi', set it to args explicitly. + // It's because ebitenmobile's default API level is different from gomobile's one. + if buildTarget == "android" && buildAndroidAPI == minAndroidAPI { + var found bool + flag.Visit(func(f *flag.Flag) { + if f.Name == "androidapi" { + found = true + } + }) + if !found { + args = append([]string{args[0], "-androidapi", fmt.Sprintf("%d", minAndroidAPI)}, args[1:]...) + } + } + if err := doBind(args, &flagset, buildTarget); err != nil { log.Fatal(err) }