diff --git a/.changes/android-template.md b/.changes/android-template.md new file mode 100644 index 00000000..8f649619 --- /dev/null +++ b/.changes/android-template.md @@ -0,0 +1,5 @@ +--- +"tauri-mobile": "patch" +--- + +Fix Android template generation. diff --git a/src/android/project.rs b/src/android/project.rs index a5d1d56f..9cdd0d08 100644 --- a/src/android/project.rs +++ b/src/android/project.rs @@ -140,12 +140,15 @@ pub fn gen( map.insert("android-app-plugins", metadata.app_plugins()); map.insert( "android-project-dependencies", - metadata.project_dependencies(), + metadata.project_dependencies().unwrap_or_default(), + ); + map.insert( + "android-app-dependencies", + metadata.app_dependencies().unwrap_or_default(), ); - map.insert("android-app-dependencies", metadata.app_dependencies()); map.insert( "android-app-dependencies-platform", - metadata.app_dependencies_platform(), + metadata.app_dependencies_platform().unwrap_or_default(), ); map.insert( "has-code", diff --git a/templates/platforms/android-studio/app/build.gradle.kts.hbs b/templates/platforms/android-studio/app/build.gradle.kts.hbs index ba9e88f0..50d35b72 100644 --- a/templates/platforms/android-studio/app/build.gradle.kts.hbs +++ b/templates/platforms/android-studio/app/build.gradle.kts.hbs @@ -1,7 +1,6 @@ plugins { id("com.android.application") - id("rust") - {{#if android-app-plugins}}{{~#each android-app-plugins}} + id("rust"){{#if android-app-plugins}}{{~#each android-app-plugins}} id("{{this}}"){{/each}}{{/if}} } @@ -26,8 +25,7 @@ android { isDebuggable = true isJniDebuggable = true isMinifyEnabled = false - packaging { - {{~#each abi-list}} + packaging { {{~#each abi-list}} jniLibs.keepDebugSymbols.add("*/{{this}}/*.so"){{/each}} } } @@ -49,9 +47,7 @@ rust { rootDirRel = "{{root-dir-rel}}" } -dependencies { - {{#if android-app-dependencies-platform}}{{~#each android-app-dependencies-platform}} - implementation(platform("{{this}}")){{/each}}{{/if}} - {{#if android-app-dependencies}}{{~#each android-app-dependencies}} - implementation("{{this}}"){{/each}}{{/if}} +dependencies { {{~#each android-app-dependencies-platform}} + implementation(platform("{{this}}")){{/each}}{{~#each android-app-dependencies}} + implementation("{{this}}"){{/each}} } diff --git a/templates/platforms/android-studio/build.gradle.kts.hbs b/templates/platforms/android-studio/build.gradle.kts.hbs index 47aa73d5..16380468 100644 --- a/templates/platforms/android-studio/build.gradle.kts.hbs +++ b/templates/platforms/android-studio/build.gradle.kts.hbs @@ -4,9 +4,8 @@ buildscript { mavenCentral() } dependencies { - classpath("com.android.tools.build:gradle:8.0.0") - {{#if android-project-dependencies}}{{~#each android-project-dependencies}} - classpath("{{this}}"){{/each}}{{/if}} + classpath("com.android.tools.build:gradle:8.0.0"){{~#each android-project-dependencies}} + classpath("{{this}}"){{/each}} } }