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
5 changes: 5 additions & 0 deletions .changes/enableEdgeToEdge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-mobile2": minor
---

Enable edge to edge in Android template for dioxus and wry
5 changes: 5 additions & 0 deletions .changes/gradle-9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-mobile2": minor
---

Updated Gradle to 9.7 and AGP to 9.3.1. This also removed the kotlin plugin in favor of the built-in kotlin from Gradle 9
5 changes: 5 additions & 0 deletions .changes/tao-wry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-mobile2": patch
---

Updated tao to 0.37 and wry 0.57 in the `wry` template
5 changes: 5 additions & 0 deletions .changes/targetSdk-37.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"cargo-mobile2": patch
---

Updated `targetSdk` to 37 (Android 17)
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
Check_Formatting:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7
- uses: hecrj/setup-rust-action@v1
with:
rust-version: stable
Expand All @@ -44,11 +44,11 @@ jobs:

runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- uses: hecrj/setup-rust-action@v1
- uses: dtolnay/rust-toolchain@stable
with:
rust-version: ${{ matrix.rust_version }}${{ matrix.platform.host }}
toolchain: ${{ matrix.rust_version }}
targets: ${{ matrix.platform.target }}

- name: Check documentation
Expand Down
10 changes: 6 additions & 4 deletions templates/apps/dioxus/Cargo.toml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ path = "gen/bin/desktop.rs"
app-activity-name = "{{app.identifier}}.MainActivity"
app-dependencies = [
"androidx.webkit:webkit:1.6.1",
"androidx.appcompat:appcompat:1.6.1",
"com.google.android.material:material:1.8.0",
"androidx.appcompat:appcompat:1.7.1",
"com.google.android.material:material:1.12.0",
"androidx.activity:activity-ktx:1.10.1",
"androidx.lifecycle:lifecycle-process:2.10.0",
]
project-dependencies = [ "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21" ]
app-plugins = [ "org.jetbrains.kotlin.android" ]
project-dependencies = []
app-plugins = []
app-permissions = [ "android.permission.INTERNET" ]
app-theme-parent = "Theme.MaterialComponents.DayNight.DarkActionBar"
vulkan-validation = false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
package {{escape-kotlin-keyword app.identifier}}

class MainActivity : WryActivity()
import android.os.Bundle
import androidx.activity.enableEdgeToEdge

class MainActivity : WryActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
}
}

6 changes: 3 additions & 3 deletions templates/apps/egui/Cargo.toml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ path = "gen/bin/desktop.rs"
app-dependencies = [
"com.google.android.material:material:1.8.0",
]
project-dependencies = [ "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21" ]
app-plugins = [ "org.jetbrains.kotlin.android" ]
project-dependencies = []
app-plugins = []
app-theme-parent = "Theme.MaterialComponents.DayNight.DarkActionBar"

[dependencies]
[dependencies]
log = "0.4.14"
chrono = "0.4"
pollster = "0.2"
Expand Down
14 changes: 8 additions & 6 deletions templates/apps/wry/Cargo.toml.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ path = "gen/bin/desktop.rs"
app-activity-name = "{{app.identifier}}.MainActivity"
app-dependencies = [
"androidx.webkit:webkit:1.6.1",
"androidx.appcompat:appcompat:1.6.1",
"com.google.android.material:material:1.8.0",
"androidx.appcompat:appcompat:1.7.1",
"com.google.android.material:material:1.12.0",
"androidx.activity:activity-ktx:1.10.1",
"androidx.lifecycle:lifecycle-process:2.10.0",
]
project-dependencies = [ "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21" ]
app-plugins = [ "org.jetbrains.kotlin.android" ]
project-dependencies = []
app-plugins = []
app-permissions = [ "android.permission.INTERNET" ]
app-theme-parent = "Theme.MaterialComponents.DayNight.DarkActionBar"
vulkan-validation = false
Expand All @@ -35,8 +37,8 @@ frameworks = [ "WebKit" ]
[dependencies]
anyhow = "1.0"
log = "0.4"
wry = "0.46"
tao = "0.30"
wry = "0.57"
tao = "0.37"

[target.'cfg(target_os = "android")'.dependencies]
android_logger = "0.13"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
package {{escape-kotlin-keyword app.identifier}}

class MainActivity : WryActivity()
import android.os.Bundle
import androidx.activity.enableEdgeToEdge

class MainActivity : WryActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()
super.onCreate(savedInstanceState)
}
}

4 changes: 2 additions & 2 deletions templates/apps/wry/src/lib.rs.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub extern "C" fn start_app() {
tao::android_binding!(
{{snake-case (ident-no-last-part app.identifier)}},
{{snake-case (ident-last-part app.name)}},
WryActivity,
Rust,
wry::android_setup, // pass the wry::android_setup function to tao which will invoke when the event loop is created
_start_app
);
Expand Down Expand Up @@ -83,7 +83,7 @@ fn build_webview(event_loop: &EventLoopWindowTarget<()>) -> anyhow::Result<WebVi
let window = WindowBuilder::new()
.with_title("A fantastic window!")
.build(&event_loop)?;

let builder = WebViewBuilder::new()
.with_url("https://tauri.app")
// If you want to use custom protocol, set url like this and add files like index.html to assets directory.
Expand Down
20 changes: 13 additions & 7 deletions templates/platforms/android-studio/app/build.gradle.kts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ plugins {
android {
namespace="{{app.identifier}}"{{#if has-asset-packs}}
assetPacks += mutableSetOf({{quote-and-join-colon-prefix asset-packs}}){{/if}}
compileSdk = 34
compileSdk = 37
defaultConfig {
applicationId = "{{app.identifier}}"
minSdk = {{android.min-sdk-version}}
targetSdk = 34
targetSdk = 37
versionCode = 1
versionName = "1.0"
}{{#if android-vulkan-validation}}
Expand All @@ -30,14 +30,20 @@ android {
}
}
getByName("release") {
isMinifyEnabled = true
proguardFiles(
*fileTree(".") { include("**/*.pro") }
.plus(getDefaultProguardFile("proguard-android-optimize.txt"))
.toList().toTypedArray()
optimization {
enable = true
}
proguardFiles(
*fileTree(".") {
include("**/*.pro")
exclude("build/**")
}.files.toTypedArray()
)
}
}
buildFeatures {
buildConfig = true
}
}

rust {
Expand Down
2 changes: 1 addition & 1 deletion templates/platforms/android-studio/build.gradle.kts.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:8.0.0"){{~#each android-project-dependencies}}
classpath("com.android.tools.build:gradle:9.3.1"){{~#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.0.0")
implementation("com.android.tools.build:gradle:9.3.1")
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,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 @@ -19,8 +26,7 @@ open class BuildTask : DefaultTask() {
val target = target ?: throw GradleException("target cannot be null")
val release = release ?: throw GradleException("release cannot be null")

project.exec {
workingDir(File(project.projectDir, rootDirRel))
execOperations.exec {
executable("cargo")
args(listOf("android", "build"))
if (project.logger.isEnabled(LogLevel.DEBUG)) {
Expand All @@ -35,4 +41,3 @@ open class BuildTask : DefaultTask() {
}.assertNormalExitValue()
}
}

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
10 changes: 0 additions & 10 deletions templates/platforms/android-studio/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,5 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# 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.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=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.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Loading
Loading