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

ndk-build,cargo-apk: Default target_sdk_version to 30 or lower #203

Merged
merged 1 commit into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions cargo-apk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

- Use `min_sdk_version` to select compiler target instead of `target_sdk_version` ([#197](https://github.com/rust-windowing/android-ndk-rs/pull/197)).
See https://developer.android.com/ndk/guides/sdk-versions#minsdkversion for more details.
- Default `target_sdk_version` to `30` or lower (instead of the highest supported SDK version by the detected NDK toolchain)
for more consistent interaction with Android backwards compatibility handling and its increasingly strict usage rules:
https://developer.android.com/distribute/best-practices/develop/target-sdk

# 0.8.2 (2021-11-22)

Expand Down
6 changes: 3 additions & 3 deletions cargo-apk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ runtime_libs = "path/to/libs_folder"

# See https://developer.android.com/guide/topics/manifest/uses-sdk-element
#
# Defaults to a `min_sdk_version` of 23 and `target_sdk_version` is based on the ndk's default platform.
# Defaults to a `min_sdk_version` of 23 and `target_sdk_version` of 30 (or lower if the detected NDK doesn't support this).
[package.metadata.android.sdk]
min_sdk_version = 16
target_sdk_version = 29
min_sdk_version = 23
target_sdk_version = 30
max_sdk_version = 29

# See https://developer.android.com/guide/topics/manifest/uses-feature-element
Expand Down
4 changes: 2 additions & 2 deletions cargo-apk/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ impl<'a> ApkBuilder<'a> {
.android_manifest
.sdk
.target_sdk_version
.get_or_insert(ndk.default_platform());
.get_or_insert_with(|| ndk.default_target_platform());

manifest
.android_manifest
.application
.debuggable
.get_or_insert(*cmd.profile() == Profile::Dev);
.get_or_insert_with(|| *cmd.profile() == Profile::Dev);

Ok(Self {
cmd,
Expand Down
6 changes: 5 additions & 1 deletion ndk-build/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

- Default `target_sdk_version` to `30` or lower (instead of the highest supported SDK version by the detected NDK toolchain)
for more consistent interaction with Android backwards compatibility handling and its increasingly strict usage rules:
https://developer.android.com/distribute/best-practices/develop/target-sdk

# 0.4.3 (2021-11-22)

- Provide NDK `build_tag` version from `source.properties` in the NDK root.
Expand All @@ -23,7 +27,7 @@

# 0.2.0 (2021-04-20)

- **Breaking:** refactored `Manifest` into a proper (de)serialization struct. `Manifest` now closely matches [`an android manifest file`](https://developer.android.com/guide/topics/manifest/manifest-element).
- **Breaking:** refactored `Manifest` into a proper (de)serialization struct. `Manifest` now closely matches [an android manifest file](https://developer.android.com/guide/topics/manifest/manifest-element).
- **Breaking:** removed `Config` in favor of using the new `Manifest` struct directly. Instead of using `Config::from_config` to create a `Manifest`, now you instantiate `Manifest` directly using, almost all, the same values.

# 0.1.4 (2020-11-25)
Expand Down
2 changes: 1 addition & 1 deletion ndk-build/src/apk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl ApkConfig {
.manifest
.sdk
.target_sdk_version
.unwrap_or_else(|| self.ndk.default_platform());
.unwrap_or_else(|| self.ndk.default_target_platform());
let mut aapt = self.build_tool(bin!("aapt"))?;
aapt.arg("package")
.arg("-f")
Expand Down
10 changes: 9 additions & 1 deletion ndk-build/src/ndk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,18 @@ impl Ndk {
Ok(Command::new(dunce::canonicalize(path)?))
}

pub fn default_platform(&self) -> u32 {
pub fn highest_supported_platform(&self) -> u32 {
self.platforms().iter().max().cloned().unwrap()
}

/// Returns platform `30` as currently [required by Google Play], or lower
/// when the detected SDK does not support it yet.
///
/// [required by Google Play]: https://developer.android.com/distribute/best-practices/develop/target-sdk
pub fn default_target_platform(&self) -> u32 {
self.highest_supported_platform().min(30)
}

pub fn platform_dir(&self, platform: u32) -> Result<PathBuf, NdkError> {
let dir = self
.sdk_path
Expand Down