cmd/ebitenmobile: update the default Android SDK version to 21

This commit is contained in:
Hajime Hoshi 2024-03-27 13:56:00 +09:00
parent 25a814d561
commit 5c0c084b6e

View File

@ -54,11 +54,6 @@ func goEnv(name string) string {
return strings.TrimSpace(string(val)) return strings.TrimSpace(string(val))
} }
const (
// Copied from gomobile.
minAndroidAPI = 15
)
var ( var (
buildA bool // -a buildA bool // -a
buildI bool // -i buildI bool // -i
@ -99,6 +94,11 @@ func main() {
flag.Usage() 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 var flagset flag.FlagSet
flagset.StringVar(&buildO, "o", "", "") flagset.StringVar(&buildO, "o", "", "")
flagset.StringVar(&buildGcflags, "gcflags", "", "") flagset.StringVar(&buildGcflags, "gcflags", "", "")
@ -150,6 +150,20 @@ func main() {
log.Fatal(err) 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 { if err := doBind(args, &flagset, buildTarget); err != nil {
log.Fatal(err) log.Fatal(err)
} }