@@ -108,91 +108,6 @@ echo "✓ USB device filter created successfully!"
108108# The manifest intent filters and permissions are sufficient for device discovery
109109echo " Skipping custom MainActivity (not needed for USB serial permissions)"
110110
111- # Add USB serial library dependency to app build.gradle.kts
112- if [ -f " $APP_BUILD_GRADLE " ]; then
113- # Add JitPack repository directly to app build.gradle.kts (fallback if settings.gradle.kts injection fails)
114- echo " Adding JitPack repository to app build.gradle.kts..."
115- if ! grep -q " jitpack.io" " $APP_BUILD_GRADLE " ; then
116- # Insert repositories block at the top of the file, after any existing buildscript/plugins blocks
117- awk '
118- BEGIN { inserted=0 }
119- {
120- print
121- # Insert after plugins or buildscript block closes, or before first line if no such blocks
122- if (!inserted && (NR==1 || $0 ~ /^plugins \{/ || $0 ~ /^buildscript \{/)) {
123- if ($0 ~ /^\}/ || NR==1) {
124- print ""
125- print "repositories {"
126- print " maven { url = uri(\"https://jitpack.io\") }"
127- print "}"
128- print ""
129- inserted=1
130- }
131- }
132- }
133- END {
134- if (!inserted) {
135- print ""
136- print "repositories {"
137- print " maven { url = uri(\"https://jitpack.io\") }"
138- print "}"
139- print ""
140- }
141- }
142- ' " $APP_BUILD_GRADLE " > " $APP_BUILD_GRADLE .tmp" && mv " $APP_BUILD_GRADLE .tmp" " $APP_BUILD_GRADLE "
143- echo " ✓ JitPack repository added to app build.gradle.kts"
144- else
145- echo " JitPack repository already present in app build.gradle.kts"
146- fi
147-
148- echo " Adding USB serial library dependency..."
149- if ! grep -q " usb-serial-for-android" " $APP_BUILD_GRADLE " ; then
150- # Check if dependencies block exists
151- if grep -q " ^dependencies {" " $APP_BUILD_GRADLE " ; then
152- echo " Inserting into existing dependencies block..."
153- # Use awk to insert after the dependencies { line (portable)
154- awk ' /^dependencies \{/ {
155- print
156- print " // USB Serial library for Android - explicit version to override plugin transitive 3.8.1"
157- print " implementation(\"com.github.mik3y:usb-serial-for-android:3.8.0\")"
158- next
159- }
160- { print }' " $APP_BUILD_GRADLE " > " $APP_BUILD_GRADLE .tmp" && mv " $APP_BUILD_GRADLE .tmp" " $APP_BUILD_GRADLE "
161- echo " ✓ USB serial library dependency added!"
162- else
163- echo " No dependencies block found, appending new block..."
164- cat >> " $APP_BUILD_GRADLE " << 'EOF '
165-
166- dependencies {
167- // USB Serial library for Android - explicit version to override plugin transitive 3.8.1
168- implementation("com.github.mik3y:usb-serial-for-android:3.8.0")
169- }
170- EOF
171- echo " ✓ USB serial library dependency added!"
172- fi
173- else
174- echo " USB serial library dependency already present"
175- fi
176-
177- # Add resolution strategy to force version 3.8.0
178- echo " Adding version resolution strategy..."
179- if ! grep -q " resolutionStrategy" " $APP_BUILD_GRADLE " ; then
180- cat >> " $APP_BUILD_GRADLE " << 'EOF '
181-
182- configurations.all {
183- resolutionStrategy {
184- force("com.github.mik3y:usb-serial-for-android:3.8.0")
185- }
186- }
187- EOF
188- echo " ✓ Resolution strategy added to force version 3.8.0"
189- else
190- echo " Resolution strategy already present"
191- fi
192- else
193- echo " Warning: $APP_BUILD_GRADLE not found, skipping dependency addition"
194- fi
195-
196111echo " "
197112echo " ✓ Android USB support configuration complete!"
198113echo " You can now build the Android app with: cargo tauri android build"
@@ -218,7 +133,4 @@ pluginManagement {
218133 }
219134}
220135EOF
221- echo " ✓ settings.gradle.kts created and injected with JitPack and required repositories."
222- else
223- echo " settings.gradle.kts already exists, checking for JitPack and required blocks..."
224136fi
0 commit comments