Skip to content
Draft
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
16 changes: 14 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Setup Java 17
- name: Setup Java 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

- name: Setup Android SDK
uses: android-actions/setup-android@v3
Expand All @@ -151,6 +151,18 @@ jobs:
- name: Initialize Tauri Android project
run: yarn tauri android init --ci

- name: Ensure JitPack repository (for usb-serial-for-android)
shell: bash
run: |
set -euo pipefail
FILE="src-tauri/gen/android/build.gradle.kts"
echo "Ensuring JitPack repository is present in $FILE"
if ! grep -q 'jitpack.io' "$FILE"; then
printf '\nallprojects {\n repositories {\n maven(url = "https://jitpack.io")\n }\n}\n' >> "$FILE"
fi
echo "Repositories block in $FILE now contains:"
grep -n "jitpack.io" "$FILE" || true
Comment on lines +154 to +164
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Review the repository injection approach for potential Gradle syntax conflicts.

The current implementation appends an allprojects block to build.gradle.kts if JitPack is not found. This could create duplicate allprojects blocks or improper nesting if the file already contains such a block, potentially leading to Gradle build failures.

Consider these alternatives:

  1. Check for existing allprojects block and append within it:
 run: |
   set -euo pipefail
   FILE="src-tauri/gen/android/build.gradle.kts"
   echo "Ensuring JitPack repository is present in $FILE"
   if ! grep -q 'jitpack.io' "$FILE"; then
-    printf '\nallprojects {\n    repositories {\n        maven(url = "https://jitpack.io")\n    }\n}\n' >> "$FILE"
+    if grep -q 'allprojects' "$FILE"; then
+      # Insert into existing allprojects block (requires more complex sed/awk)
+      echo "Warning: allprojects block exists, manual insertion needed"
+    else
+      printf '\nallprojects {\n    repositories {\n        maven(url = "https://jitpack.io")\n    }\n}\n' >> "$FILE"
+    fi
   fi
  1. Use Gradle init script instead of modifying generated files:
mkdir -p ~/.gradle/init.d
cat > ~/.gradle/init.d/jitpack.gradle.kts << 'EOF'
allprojects {
    repositories {
        maven(url = "https://jitpack.io")
    }
}
EOF

The Gradle init script approach is cleaner as it avoids modifying generated files.

🤖 Prompt for AI Agents
.github/workflows/ci.yml around lines 154-164: the workflow currently appends a
new allprojects block to src-tauri/gen/android/build.gradle.kts which can create
duplicate blocks or invalid nesting; replace this with a safer approach: detect
an existing allprojects { ... } block and insert the jitpack maven entry into
its repositories section if present (or create a repositories block inside that
allprojects block if missing), otherwise fallback to creating a Gradle init
script under ~/.gradle/init.d/jitpack.gradle.kts that adds the allprojects {
repositories { maven(url = "https://jitpack.io") } } entry so generated files
are not modified; update the CI step to perform the detection-and-insert logic
and, if insertion into the generated file isn’t possible, create the init.d file
instead.


- name: Build Tauri Android APK
uses: tauri-apps/tauri-action@v0
with:
Expand Down
33 changes: 29 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
retention-days: 30

android:
name: Android APK (Capacitor)
name: Android APK (Tauri)
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -79,11 +79,21 @@ jobs:
- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Setup Java 11
- name: Setup Java 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '11'
java-version: '21'

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-linux-android,armv7-linux-androideabi,i686-linux-android,x86_64-linux-android

- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri

- name: Cache Gradle
uses: actions/cache@v4
Expand All @@ -95,9 +105,24 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-

- name: Ensure JitPack repository (for usb-serial-for-android)
shell: bash
run: |
set -euo pipefail
FILE="src-tauri/gen/android/build.gradle.kts"
if [ -f "$FILE" ]; then
echo "Ensuring JitPack repository is present in $FILE"
if ! grep -q 'jitpack.io' "$FILE"; then
printf '\nallprojects {\n repositories {\n maven(url = "https://jitpack.io")\n }\n}\n' >> "$FILE"
fi
grep -n "jitpack.io" "$FILE" || true
else
echo "Warning: $FILE not found (will be generated by Tauri on first build)."
fi
Comment on lines +108 to +121
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Same repository injection concern as ci.yml.

This has the same potential issue with appending allprojects blocks as noted in the ci.yml workflow (lines 154-164). Consider using a Gradle init script instead of modifying generated files.

The file existence check is a good addition, but the append approach can still create duplicate blocks if the file already contains an allprojects section. Refer to the review comment on ci.yml lines 154-164 for suggested alternatives.

🤖 Prompt for AI Agents
.github/workflows/release.yml lines 108-121: the workflow appends an allprojects
{ repositories { maven(url = "https://jitpack.io") } } block directly into
src-tauri/gen/android/build.gradle.kts which can create duplicate or conflicting
allprojects sections; instead make the change idempotent by either (a) creating
a Gradle init script (e.g. in .github/workflows or repo root) that adds the
jitpack repository for all builds and reference that in CI, or (b) if you must
edit the generated file, detect an existing allprojects block and inject/merge
the jitpack repository into that block rather than appending a new allprojects
section, ensuring the check is robust (search for an existing allprojects { ...
} and for jitpack.io) before writing.


- name: Build Android release (unsigned)
run: |
yarn android:release
yarn tauri:build:android

- name: Setup release keystore (if available)
if: ${{ secrets.ANDROID_KEYSTORE_BASE64 != '' }}
Expand Down
5 changes: 2 additions & 3 deletions src-tauri/Cargo.lock

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

11 changes: 4 additions & 7 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ tauri-build = { version = "2.5", features = [] }
[dependencies]
tauri = { version = "2.9", features = [] }
tauri-plugin-shell = "2.3"
# Allow newer serial plugin releases (2.21+) which may include Android fixes
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-serialplugin = "2.21"

[target.'cfg(target_os = "android")'.dependencies]
serialport = "4.8"
# Pin exact version to avoid pulling 2.21.x which is incompatible with current Android/Kotlin setup
# Try an older plugin version that matches tauri-android 2.9 API surface (avoid onDetach override)
# Further downgrade to avoid onDetach override incompatibility
tauri-plugin-serialplugin = "=2.15.0"
Comment on lines +23 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Consolidate redundant comments and verify the pinned version.

The three comment lines explaining the version pin are somewhat redundant. Consider consolidating them for clarity.

Apply this diff to consolidate the comments:

-# Pin exact version to avoid pulling 2.21.x which is incompatible with current Android/Kotlin setup
-# Try an older plugin version that matches tauri-android 2.9 API surface (avoid onDetach override)
-# Further downgrade to avoid onDetach override incompatibility
+# Pinned to 2.15.0: versions 2.21+ have onDetach override incompatibility with tauri-android 2.9 API
 tauri-plugin-serialplugin = "=2.15.0"

Verify that version 2.15.0 exists and check for any security advisories:

Additionally, you may want to verify the plugin version on crates.io:


🏁 Script executed:

#!/bin/bash
# Description: Check if tauri-plugin-serialplugin 2.15.0 exists and look for security issues

# Search for any published versions or release info in the repository
rg -n "2\.15\.0|2\.21" -g "*.md" -g "*.toml" -C 2

# Check Cargo.lock for the resolved version
if [ -f "Cargo.lock" ]; then
  grep -A 5 "name = \"tauri-plugin-serialplugin\"" Cargo.lock | head -10
else
  echo "No Cargo.lock found"
fi

Length of output: 625


🌐 Web query:

What versions of tauri-plugin-serialplugin are available on crates.io, and are there any known issues with version 2.15.0?

💡 Result:

Short answer:

  • Available releases (per the plugin repo tags): 2.16.0, 2.10.0, 2.4.14, 2.4.12, v2.1.0 (the repository’s tags/releases page shows 2.16.0 as the newest). [1]

  • Known issues for 2.15.0: I could not find any open/recorded issues specifically referencing version 2.15.0 in the plugin’s issue tracker. No repo issues specifically mention 2.15.0. If you want a definitive crates.io list and publish dates or any crate-specific bug reports tied to the crates.io release, I can fetch the crates.io API page and scan issue trackers again. [1][2]

Sources:

  1. GitHub tags/releases for s00d/tauri-plugin-serialplugin (tags list includes 2.16.0 etc.). [turn6view0].
  2. Repository issues overview (no matches for “2.15.0” in open issues). [turn2view1].

Fix the pinned version: 2.15.0 does not exist on crates.io.

The web search confirms that available versions are 2.16.0, 2.10.0, 2.4.14, 2.4.12, and v2.1.0—version 2.15.0 is not among them. This will cause build failures.

Issues:

  • Exact version pin "=2.15.0" targets a non-existent release
  • Must use an available version (likely 2.10.0 or 2.16.0) that satisfies the Android/Kotlin compatibility constraints mentioned in the comments
  • The three comment lines should also be consolidated once the correct version is identified

Action required: Verify which available version resolves the onDetach override incompatibility, update the pin accordingly, and consolidate the comments into a single line explaining the constraint.


[features]
default = ["custom-protocol"]
Expand Down
22 changes: 3 additions & 19 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,9 @@
)]

fn main() {
let mut builder = tauri::Builder::default()
.plugin(tauri_plugin_shell::init());

#[cfg(target_os = "android")]
{
// Local Android serial plugin that mirrors the commands used by the frontend
builder = builder.plugin(crate::serial_android::init_android());
}

#[cfg(not(target_os = "android"))]
{
// Desktop: use official plugin for now
builder = builder.plugin(tauri_plugin_serialplugin::init());
}

builder
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.plugin(tauri_plugin_serialplugin::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

#[cfg(target_os = "android")]
mod serial_android;
120 changes: 0 additions & 120 deletions src-tauri/src/serial_android.rs

This file was deleted.