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

feature: enable to set android min api #295

Merged
merged 2 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/src/doc/user-guide/exporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ On android, we do not embed a JVM, we use the existing ART provided by the OS. I
}
```

- Setting the `androidMinApi` (equivalent to `--min-api` argument of `d8` tool), default is `21`:
```kt
godot {
androidMinApi = 22
}
```

!!! warning
Similar to the desktop targets, the game copies the needed jar files to the `user://` directory upon first execution or if the files have changed. On android this is the applications `files` folder. If you do IO operations on Android, never empty the whole `files` folder! Only delete what you have added or exclude the following two files when clearing the `files` folder: `godot-bootstrap-dex.jar` and `main-dex.jar`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ open class GodotExtension(objects: ObjectFactory) {
*/
var androidCompileSdkDir = objects.fileProperty()

/**
* Min android api version.
*
* example: 21
*/
var androidMinApi = objects.property(Int::class.java)

/**
* enable Graal Native Image Export
*
Expand Down Expand Up @@ -88,6 +95,8 @@ open class GodotExtension(objects: ObjectFactory) {
androidCompileSdkDir.set(androidCompileSdkDirFile)
}

androidMinApi.set(21)

isGraalNativeImageExportEnabled.set(false)
nativeImageToolPath.set(System.getenv("native-image")?.let { File(it) })
additionalGraalJniConfigurationFiles.set(arrayOf())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ fun Project.createMainDexFileTask(
mainJar.absolutePath,
"--lib",
"${godotJvmExtension.androidCompileSdkDir.get().asFile.absolutePath}${File.separator}android.jar",
"--min-api",
godotJvmExtension.androidMinApi.get(),
)
} else {
commandLine(
Expand All @@ -49,6 +51,8 @@ fun Project.createMainDexFileTask(
"${godotJvmExtension.androidCompileSdkDir.get().asFile.absolutePath}/android.jar",
"--classpath",
godotBootstrapJar.absolutePath,
"--min-api",
godotJvmExtension.androidMinApi.get(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ fun Project.packageBootstrapDexJarTask(
"godot-bootstrap-dex.jar",
"--lib",
"${godotJvmExtension.androidCompileSdkDir.get().asFile.absolutePath}${File.separator}android.jar",
"--min-api",
godotJvmExtension.androidMinApi.get(),
)
} else {
commandLine(
Expand All @@ -45,6 +47,8 @@ fun Project.packageBootstrapDexJarTask(
"godot-bootstrap-dex.jar",
"--lib",
"${godotJvmExtension.androidCompileSdkDir.get().asFile.absolutePath}/android.jar",
"--min-api",
godotJvmExtension.androidMinApi.get(),
)
}
}
Expand Down