Skip to content

Commit cdded41

Browse files
committed
docs(android-setup): add JitPack configuration instructions for Android builds
1 parent fdc4413 commit cdded41

1 file changed

Lines changed: 74 additions & 4 deletions

File tree

README.md

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,46 @@ npm install tauri-plugin-serialplugin-api
9797
pnpm add tauri-plugin-serialplugin-api
9898
```
9999

100+
### Android Setup (Required for Android builds)
101+
102+
> **⚠️ Important:** If you're building for Android, you **must** configure the JitPack repository before building. The plugin will not compile without this step.
103+
104+
The plugin depends on `com.github.mik3y:usb-serial-for-android:3.8.1`, which is hosted on JitPack. Add the following to your `/src-tauri/gen/android/build.gradle.kts` file:
105+
106+
```kotlin
107+
buildscript {
108+
repositories {
109+
google()
110+
mavenCentral()
111+
maven { url = uri("https://jitpack.io") }
112+
}
113+
dependencies {
114+
classpath("com.android.tools.build:gradle:8.11.0")
115+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
116+
// ... your other dependencies
117+
}
118+
}
119+
120+
allprojects {
121+
repositories {
122+
google()
123+
mavenCentral()
124+
maven { url = uri("https://jitpack.io") }
125+
}
126+
}
127+
128+
tasks.register("clean").configure {
129+
delete("build")
130+
}
131+
```
132+
133+
**Without this configuration, you will get an error:**
134+
```
135+
could not find com.github.mik3y:usb-serial-for-android:3.8.1
136+
```
137+
138+
For more details and troubleshooting, see the [Android Setup](#android-setup) section.
139+
100140
---
101141

102142
## Basic Usage
@@ -1620,24 +1660,54 @@ await port.disableAutoReconnect();
16201660

16211661
## Android Setup
16221662

1623-
To use this plugin on Android, you need to add the JitPack repository to your project's `build.gradle.kts` file located at `/src-tauri/gen/android/build.gradle.kts`. Below is an example of how to configure it:
1663+
To use this plugin on Android, you **must** add the JitPack repository to your project's `build.gradle.kts` file located at `/src-tauri/gen/android/build.gradle.kts`. This is required because the plugin depends on `com.github.mik3y:usb-serial-for-android:3.8.1`, which is hosted on JitPack.
1664+
1665+
### Required Configuration
1666+
1667+
Add the JitPack repository to both `buildscript` and `allprojects` sections:
16241668

16251669
```kotlin
16261670
buildscript {
16271671
repositories {
1628-
// ...
1672+
google()
1673+
mavenCentral()
16291674
maven { url = uri("https://jitpack.io") }
16301675
}
1631-
// ...
1676+
dependencies {
1677+
classpath("com.android.tools.build:gradle:8.11.0")
1678+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
1679+
// ... your other dependencies
1680+
}
16321681
}
16331682

16341683
allprojects {
16351684
repositories {
1636-
// ...
1685+
google()
1686+
mavenCentral()
16371687
maven { url = uri("https://jitpack.io") }
16381688
}
16391689
}
1690+
1691+
tasks.register("clean").configure {
1692+
delete("build")
1693+
}
1694+
```
1695+
1696+
### Why is this needed?
1697+
1698+
The plugin uses the [usb-serial-for-android](https://github.com/mik3y/usb-serial-for-android) library, which is published on JitPack rather than Maven Central. Without adding JitPack to your repositories, Gradle will fail with an error like:
1699+
16401700
```
1701+
could not find com.github.mik3y:usb-serial-for-android:3.8.1
1702+
```
1703+
1704+
### Troubleshooting
1705+
1706+
If you still encounter issues after adding JitPack:
1707+
1708+
1. Make sure you've added it to **both** `buildscript.repositories` and `allprojects.repositories`
1709+
2. Sync your Gradle files in your IDE
1710+
3. Clean and rebuild your project: `./gradlew clean build`
16411711

16421712
---
16431713

0 commit comments

Comments
 (0)