Commit 2ca4ab3
authored
Add Android on-device debugging support (#5012)
* Add Android on-device debugging support
Mirrors the iOS on-device-debug flow from #4999 for Android, taking
advantage of the fact that Dalvik/ART already speaks JDWP — no
desktop proxy needed. The Codename One Maven plugin orchestrates adb:
install the APK, mark it as the debug-app, launch the Activity, poll
for the PID, forward JDWP onto localhost, and tail logcat. The
existing IntelliJ workflow extends: there is now a CN1 Android
On-Device Debug + CN1 Attach Android pair under the same On-Device
Debug folder as the iOS configs.
Pieces:
- AndroidGradleBuilder parses a new android.onDeviceDebug build hint
that flips the generated manifest to debuggable=true and disables
R8/proguard so symbols and locals survive the build. Release builds
(anything without the hint) are unaffected.
- cn1:android-on-device-debugging — new Mojo that drives the adb
session end-to-end, with autodetection of adb from ANDROID_HOME /
ANDROID_SDK_ROOT / standard Studio SDK paths / $PATH, optional
adb connect <ip:port> for wireless devices (Android 11+
adb pair / adb connect and legacy adb tcpip both covered), APK
autodetection from target/, am set-debug-app -w for wait-for-
attach, and a logcat stream prefixed [device] for the lifetime of
the session. Cleans up adb forward on shutdown.
- cn1:buildAndroidOnDeviceDebug — wrapper that force-sets the hint
and invokes the existing android-device cloud build, so the IDE
menu has a one-click entry that doesn't depend on the project's
codenameone_settings.properties.
Archetype:
- common/codenameone_settings.properties carries the new hint
commented out, next to the existing ios.onDeviceDebug.* lines.
- .idea/runConfigurations/CN1_Android_OnDeviceDebug.xml — Maven run
config that invokes the new Mojo from the project root.
- .idea/runConfigurations/CN1_Attach_Android.xml — Remote JVM Debug
to localhost:5005, scoped to the -common module.
Developer guide:
- New On-Device-Debugging-Android.asciidoc chapter: IntelliJ quick
start, wireless debugging (both Android 11+ and legacy paths),
Maven CLI flow, flag table, source-resolution for both
codenameone-core and codenameone-android sources jars, and
troubleshooting. Explicitly calls out that JNI C/C++ is out of
scope (use Android Studio + LLDB for that, can run alongside).
- Advanced-Topics-Under-The-Hood gets an android.onDeviceDebug
entry next to the existing android.debug / android.release rows.
* Address CI feedback on Android on-device debugging
Three gates failed on the original push:
- SpotBugs DE_MIGHT_IGNORE in AndroidOnDeviceDebuggingMojo's shutdown
hook (catch-all swallowed every Exception silently). Narrow the
catch to MojoFailureException — the only checked exception runAdb
can throw — and surface the message to stderr so a stuck adb
forward is at least visible at shutdown. Process.destroy() doesn't
declare a checked exception, so the surrounding try/catch is no
longer needed for that call.
- Vale (Microsoft.Contractions + Microsoft.Adverbs) on
On-Device-Debugging-Android.adoc: "it is" → "it's"; drop "rarely"
by rewriting the command-line-flags lead sentence; drop "silently"
from the breakpoint-not-firing troubleshooter.
- LanguageTool typo flags: "codepath" → "code path" in the
waitForAttach=false note; allowlist "adb", "logcat", and "pidof"
in languagetool-accept.txt under a new "Android tooling" section
so future Android docs don't re-trip the same rule.
* android.onDeviceDebug: also disable ProGuard and pin to debug-only
Two follow-ups to the initial hint binding:
- Force off android.enableProguard alongside disableR8. ProGuard runs
on the non-Gradle-8 legacy path, and even on Gradle 8 it can layer
on top of R8 when android.enableProguard=true; either way the user
loses method names and locals. The hint now disables both
obfuscators so symbols survive the build regardless of which
Gradle line the project is on.
- Force android.release=false and android.debug=true. Android's
manifest is shared between the release and debug variants, so
android:debuggable="true" propagates to both. The cloud build also
produces both APKs by default (android.release defaults to true).
Without this pin, a stray hint left in codenameone_settings.properties
would silently ship a release-signed APK marked debuggable=true —
a serious security problem since any device that side-loads it
would be exposing a JDWP socket. Pinning to debug-only means the
release APK is simply not produced when the hint is on, and the
developer guide row for the hint now spells that out.
Companion change in the BuildDaemon's AndroidGradleBuilder (separate
repo) applies the same guard for the cloud build path.
* docs: contraction fixes in android.onDeviceDebug hint row
Vale Microsoft.Contractions flagged the expanded row on the second CI
run: "cannot" → "can't", "that is" → "that's". Same fix pattern as
the earlier batch of contraction tweaks in the Android chapter.1 parent 18502ed commit 2ca4ab3
10 files changed
Lines changed: 909 additions & 0 deletions
File tree
- docs/developer-guide
- maven
- cn1app-archetype/src/main/resources/archetype-resources
- .idea/runConfigurations
- common
- codenameone-maven-plugin/src/main/java/com/codename1
- builders
- maven
- buildWrappers
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
Lines changed: 327 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments