@@ -244,16 +244,36 @@ public void processLine(final String line) {
244
244
entry .message .contains ("Start proc" ) &&
245
245
entry .message .contains (packageName )) {
246
246
// Sample message string from logcat when starting process:
247
- // "Start proc 29318:processing.test.sketch001/u0a403 for activity processing.test.sketch001/.MainActivity"
247
+ // "Start proc 29318:processing.test.sketch001/u0a403 for activity processing.test.sketch001/.MainActivity"
248
+ boolean pidFound = false ;
249
+
248
250
try {
249
251
int idx0 = entry .message .indexOf ("Start proc" ) + 11 ;
250
252
int idx1 = entry .message .indexOf (packageName ) - 1 ;
251
253
String pidStr = entry .message .substring (idx0 , idx1 );
252
254
int pid = Integer .parseInt (pidStr );
253
255
startProc (entry .source , pid );
254
- } catch (Exception ex ) {
255
- System .err .println ("AndroidDevice: cannot find process id, console output will be disabled." );
256
- }
256
+ pidFound = true ;
257
+ } catch (Exception ex ) { }
258
+
259
+ if (!pidFound ) {
260
+ // In some cases (old adb maybe?):
261
+ // https://github.com/processing/processing-android/issues/331
262
+ // the process start line is slightly different:
263
+ // I/ActivityManager( 648): Start proc processing.test.sketch_170818a for activity processing.test.sketch_170818a/.MainActivity: pid=4256 uid=10175 gids={50175}
264
+ try {
265
+ int idx0 = entry .message .indexOf ("pid=" ) + 4 ;
266
+ int idx1 = entry .message .indexOf ("uid" ) - 1 ;
267
+ String pidStr = entry .message .substring (idx0 , idx1 );
268
+ int pid = Integer .parseInt (pidStr );
269
+ startProc (entry .source , pid );
270
+ pidFound = true ;
271
+ } catch (Exception ex ) { }
272
+
273
+ if (!pidFound ) {
274
+ System .err .println ("AndroidDevice: cannot find process id, console output will be disabled." );
275
+ }
276
+ }
257
277
} else if (packageName != null && !packageName .equals ("" ) &&
258
278
entry .message .contains ("Killing" ) &&
259
279
entry .message .contains (packageName )) {
0 commit comments