Skip to content
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
23 changes: 23 additions & 0 deletions .changes/android-consumer-proguard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
tauri: minor:deps
tauri-cli: minor:deps
"tauri-apps/cli": minor:deps
---

On Android, fix missing `consumer-rules.pro` file in the template.

**IMPORTANT**: For plugin authors, update your `build.gradle.kts` file to remove the

```kotlin
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
```

section and rename your `proguard-rules.pro` to `consumer-rules.pro` to match the `consumerProguardFiles("consumer-rules.pro")` in the template.
8 changes: 8 additions & 0 deletions .changes/android-gradle-9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
tauri: minor:deps
tauri-build: minor:deps
tauri-cli: minor:deps
"tauri-apps/cli": minor:deps
---

On Android, updated the template to use Gradle v9.6.1 (`com.android.tools.build:gradle` v9.3.1) and Kotlin v2.2. Use `tauri android init` to apply the change.
26 changes: 6 additions & 20 deletions .github/workflows/test-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,24 @@ jobs:
- name: install Rust 1.90
uses: dtolnay/rust-toolchain@1.90

- name: install Linux dependencies
if: matrix.platform == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev webkit2gtk-4.1

- run: npm i -g --force corepack
- name: setup node
uses: actions/setup-node@v7
with:
node-version: lts/*
cache: 'pnpm'

- uses: actions/setup-java@v3
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 17
cache: 'gradle'
java-version: 25
cache: gradle

- name: Setup NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r25b
ndk-version: r29
local-cache: true

# TODO check after https://github.com/nttld/setup-ndk/issues/518 is fixed
Expand All @@ -76,16 +70,8 @@ jobs:

- uses: Swatinem/rust-cache@v2

- name: build CLI
run: cargo build --manifest-path ./crates/tauri-cli/Cargo.toml

- name: move CLI to cargo bin dir
if: matrix.platform != 'windows-latest'
run: mv ./target/debug/cargo-tauri $HOME/.cargo/bin

- name: move CLI to cargo bin dir
if: matrix.platform == 'windows-latest'
run: mv ./target/debug/cargo-tauri.exe $HOME/.cargo/bin
- name: build and install CLI
run: cargo install tauri-cli --path ./crates/tauri-cli/ --locked --debug

- run: pnpm i --frozen-lockfile

Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/tauri-build/src/mobile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub fn generate_gradle_files(project_dir: PathBuf) -> Result<()> {
let mut gradle_settings =
"// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n".to_string();
let mut app_build_gradle = "// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
val implementation by configurations
val implementation = configurations.getByName(\"implementation\")
dependencies {
implementation(\"androidx.lifecycle:lifecycle-process:2.10.0\")"
.to_string();
Expand Down
21 changes: 14 additions & 7 deletions crates/tauri-cli/templates/mobile/android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.util.Properties
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.application")
Expand Down Expand Up @@ -37,20 +37,27 @@ android {
isJniDebuggable = true
isMinifyEnabled = false
packaging {
{{~#each abi-list}}
{{#each abi-list}}
jniLibs.keepDebugSymbols.add("*/{{this}}/*.so")
{{/each}}
}
}
getByName("release") {
isMinifyEnabled = true
optimization {
enable = true
}
proguardFiles(
*fileTree(".") { include("**/*.pro") }
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
.toList().toTypedArray()
*fileTree(".") {
include("**/*.pro")
exclude("build/**")
}.files.toTypedArray()
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
buildFeatures {
buildConfig = true
}
Expand Down Expand Up @@ -81,4 +88,4 @@ dependencies {
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
}

apply(from = "tauri.build.gradle.kts")
apply(from = file("tauri.build.gradle.kts"))
4 changes: 2 additions & 2 deletions crates/tauri-cli/templates/mobile/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.11.0")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
classpath("com.android.tools.build:gradle:9.3.1")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.10")
{{~#each android-project-dependencies}}
classpath("{{this}}"){{/each}}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ repositories {

dependencies {
compileOnly(gradleApi())
implementation("com.android.tools.build:gradle:8.11.0")
implementation("com.android.tools.build:gradle:9.3.1")
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ import org.gradle.api.GradleException
import org.gradle.api.logging.LogLevel
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
import javax.inject.Inject
import org.gradle.process.ExecOperations

abstract class BuildTask : DefaultTask() {
@get:Inject
abstract val execOperations: ExecOperations

open class BuildTask : DefaultTask() {
@Input
var rootDirRel: String? = null
@Input
var projectDir: String? = null
@Input
var target: String? = null
@Input
var release: Boolean? = null
Expand All @@ -27,7 +34,7 @@ open class BuildTask : DefaultTask() {
"$executable.cmd",
"$executable.bat",
)

var lastException: Exception = e
for (fallback in fallbacks) {
try {
Expand All @@ -50,13 +57,13 @@ open class BuildTask : DefaultTask() {
val release = release ?: throw GradleException("release cannot be null")
val args = listOf({{quote-and-join tauri-binary-args}});

project.exec {
workingDir(File(project.projectDir, rootDirRel))
execOperations.exec {
workingDir(File(projectDir, rootDirRel))
executable(executable)
args(args)
if (project.logger.isEnabled(LogLevel.DEBUG)) {
if (logger.isEnabled(LogLevel.DEBUG)) {
args("-vv")
} else if (project.logger.isEnabled(LogLevel.INFO)) {
} else if (logger.isEnabled(LogLevel.INFO)) {
args("-v")
}
if (release) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ open class RustPlugin : Plugin<Project> {
val targetName = targetPair.value
val targetArch = archList[targetPair.index]
val targetArchCapitalized = targetArch.replaceFirstChar { it.uppercase() }
val targetBuildTask = project.tasks.maybeCreate(
val targetBuildTask = project.tasks.register(
"rustBuild$targetArchCapitalized$profileCapitalized",
BuildTask::class.java
).apply {
) {
group = TASK_GROUP
description = "Build dynamic library in $profile mode for $targetArch"
rootDirRel = config.rootDirRel
projectDir = project.projectDir.path
target = targetName
release = profile == "release"
}
Expand Down
20 changes: 11 additions & 9 deletions crates/tauri-cli/templates/mobile/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.configuration-cache=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
android.nonFinalResIds=false

# Our old plugin template had a bug that caused missing `consumer-rules.pro` files
# so we have to disable it for now.
# See https://github.com/tauri-apps/tauri/pull/15828#issuecomment-5199937796
android.proguard.failOnMissingFiles=false

# Keeping Gradle 9 compatible with current plugins
# TODO: Remove this in v3
android.builtInKotlin=false
android.newDsl=false
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue May 10 19:22:52 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Loading
Loading