Skip to content

Commit db4c9dc

Browse files
authored
feat(core): add option to configure Android's minimum SDK version (#6651)
1 parent 63f088e commit db4c9dc

File tree

10 files changed

+647
-36
lines changed

10 files changed

+647
-36
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cli.rs": patch
3+
"tauri": patch
4+
---
5+
6+
Change minimum Android SDK version to 21 for the plugin library.

.changes/min-sdk-version.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-utils": patch
3+
---
4+
5+
Added `android` configuration object under `tauri > bundle`.

core/config-schema/schema.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
},
132132
"bundle": {
133133
"active": false,
134+
"android": {
135+
"minSdkVersion": 24
136+
},
134137
"appimage": {
135138
"bundleMediaFramework": false
136139
},
@@ -270,6 +273,9 @@
270273
"description": "The bundler configuration.",
271274
"default": {
272275
"active": false,
276+
"android": {
277+
"minSdkVersion": 24
278+
},
273279
"appimage": {
274280
"bundleMediaFramework": false
275281
},
@@ -1169,6 +1175,17 @@
11691175
"$ref": "#/definitions/IosConfig"
11701176
}
11711177
]
1178+
},
1179+
"android": {
1180+
"description": "Android configuration.",
1181+
"default": {
1182+
"minSdkVersion": 24
1183+
},
1184+
"allOf": [
1185+
{
1186+
"$ref": "#/definitions/AndroidConfig"
1187+
}
1188+
]
11721189
}
11731190
},
11741191
"additionalProperties": false
@@ -1772,6 +1789,20 @@
17721789
},
17731790
"additionalProperties": false
17741791
},
1792+
"AndroidConfig": {
1793+
"description": "General configuration for the iOS target.",
1794+
"type": "object",
1795+
"properties": {
1796+
"minSdkVersion": {
1797+
"description": "The minimum API level required for the application to run. The Android system will prevent the user from installing the application if the system's API level is lower than the value specified.",
1798+
"default": 24,
1799+
"type": "integer",
1800+
"format": "uint32",
1801+
"minimum": 0.0
1802+
}
1803+
},
1804+
"additionalProperties": false
1805+
},
17751806
"AllowlistConfig": {
17761807
"description": "Allowlist configuration. The allowlist is a translation of the [Cargo allowlist features](https://docs.rs/tauri/latest/tauri/#cargo-allowlist-features).\n\n# Notes\n\n- Endpoints that don't have their own allowlist option are enabled by default. - There is only \"opt-in\", no \"opt-out\". Setting an option to `false` has no effect.\n\n# Examples\n\n- * [`\"app-all\": true`](https://tauri.app/v1/api/config/#appallowlistconfig.all) will make the [hide](https://tauri.app/v1/api/js/app#hide) endpoint be available regardless of whether `hide` is set to `false` or `true` in the allowlist.",
17771808
"type": "object",

core/tauri-utils/src/config.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,9 @@ pub struct BundleConfig {
680680
/// iOS configuration.
681681
#[serde(rename = "iOS", default)]
682682
pub ios: IosConfig,
683+
/// Android configuration.
684+
#[serde(default)]
685+
pub android: AndroidConfig,
683686
}
684687

685688
/// A CLI argument definition.
@@ -2626,6 +2629,30 @@ pub struct IosConfig {
26262629
pub development_team: Option<String>,
26272630
}
26282631

2632+
/// General configuration for the iOS target.
2633+
#[skip_serializing_none]
2634+
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
2635+
#[cfg_attr(feature = "schema", derive(JsonSchema))]
2636+
#[serde(rename_all = "camelCase", deny_unknown_fields)]
2637+
pub struct AndroidConfig {
2638+
/// The minimum API level required for the application to run.
2639+
/// The Android system will prevent the user from installing the application if the system's API level is lower than the value specified.
2640+
#[serde(alias = "min-sdk-version", default = "default_min_sdk_version")]
2641+
pub min_sdk_version: u32,
2642+
}
2643+
2644+
impl Default for AndroidConfig {
2645+
fn default() -> Self {
2646+
Self {
2647+
min_sdk_version: default_min_sdk_version(),
2648+
}
2649+
}
2650+
}
2651+
2652+
fn default_min_sdk_version() -> u32 {
2653+
24
2654+
}
2655+
26292656
/// Defines the URL or assets to embed in the application.
26302657
#[derive(Debug, PartialEq, Eq, Clone, Deserialize, Serialize)]
26312658
#[cfg_attr(feature = "schema", derive(JsonSchema))]
@@ -3416,6 +3443,7 @@ mod build {
34163443
let external_bin = opt_vec_str_lit(self.external_bin.as_ref());
34173444
let windows = &self.windows;
34183445
let ios = quote!(Default::default());
3446+
let android = quote!(Default::default());
34193447

34203448
literal_struct!(
34213449
tokens,
@@ -3435,7 +3463,8 @@ mod build {
34353463
macos,
34363464
external_bin,
34373465
windows,
3438-
ios
3466+
ios,
3467+
android
34393468
);
34403469
}
34413470
}
@@ -3853,6 +3882,7 @@ mod test {
38533882
external_bin: None,
38543883
windows: Default::default(),
38553884
ios: Default::default(),
3885+
android: Default::default(),
38563886
},
38573887
cli: None,
38583888
updater: UpdaterConfig {

core/tauri/mobile/android/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
compileSdk = 33
99

1010
defaultConfig {
11-
minSdk = 24
11+
minSdk = 21
1212
targetSdk = 33
1313

1414
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

0 commit comments

Comments
 (0)