Skip to content

Commit d609bef

Browse files
fix(cli & core): use unescaped package id in proguard file (#11314)
* fix(cli & core): use unescaped package id in proguard file closes #11310 * add monkey patch for wry proguard * fix tests * typo * remove wry fix --------- Co-authored-by: Lucas Nogueira <[email protected]>
1 parent 4731f0c commit d609bef

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

.changes/android-proguard.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"tauri": "patch:bug"
3+
"tauri-cli": "patch:bug"
4+
"@tauri-apps/cli": "patch:bug"
5+
---
6+
7+
Fix android invalid proguard file when using an `identifier` that contains a component that is a reserved kotlin keyword, like `in`, `class`, etc

crates/tauri-cli/src/mobile/android/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ pub fn get_config(
139139
"WRY_ANDROID_PACKAGE",
140140
app.android_identifier_escape_kotlin_keyword(),
141141
);
142+
set_var("TAURI_ANDROID_PACKAGE_UNESCAPED", app.identifier());
142143
set_var("WRY_ANDROID_LIBRARY", app.lib_name());
143144
set_var("TAURI_ANDROID_PROJECT_PATH", config.project_dir());
144145

crates/tauri/build.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,13 @@ fn main() {
260260
}
261261

262262
if target_os == "android" {
263-
if let Ok(kotlin_out_dir) = std::env::var("WRY_ANDROID_KOTLIN_FILES_OUT_DIR") {
264-
fn env_var(var: &str) -> String {
265-
std::env::var(var).unwrap_or_else(|_| {
266-
panic!("`{var}` is not set, which is needed to generate the kotlin files for android.")
267-
})
268-
}
263+
fn env_var(var: &str) -> String {
264+
std::env::var(var).unwrap_or_else(|_| {
265+
panic!("`{var}` is not set, which is needed to generate the kotlin files for android.")
266+
})
267+
}
269268

269+
if let Ok(kotlin_out_dir) = std::env::var("WRY_ANDROID_KOTLIN_FILES_OUT_DIR") {
270270
let package = env_var("WRY_ANDROID_PACKAGE");
271271
let library = env_var("WRY_ANDROID_LIBRARY");
272272

@@ -299,11 +299,9 @@ fn main() {
299299
}
300300

301301
if let Some(project_dir) = env::var_os("TAURI_ANDROID_PROJECT_PATH").map(PathBuf::from) {
302-
let tauri_proguard = include_str!("./mobile/proguard-tauri.pro").replace(
303-
"$PACKAGE",
304-
&env::var("WRY_ANDROID_PACKAGE")
305-
.expect("missing `WRY_ANDROID_PACKAGE` environment variable"),
306-
);
302+
let package_unescaped = env_var("TAURI_ANDROID_PACKAGE_UNESCAPED");
303+
let tauri_proguard =
304+
include_str!("./mobile/proguard-tauri.pro").replace("$PACKAGE", &package_unescaped);
307305
std::fs::write(
308306
project_dir.join("app").join("proguard-tauri.pro"),
309307
tauri_proguard,

0 commit comments

Comments
 (0)