Android Mode crash after successful build (VerifyError: PSurfaceAndroid2D / PSurfaceNone)

Hi everyone,
I’m running into a runtime crash in Processing Android Mode. The project builds successfully, installs on the device, but crashes immediately on launch with a VerifyError.

I’m hoping someone can help confirm whether this is a Processing Android Mode bug, a version mismatch, or a known compatibility issue.


:white_check_mark: Environment

  • OS: Windows
  • Processing: (Android Mode, bundled JDK 17)
  • Android SDK: Installed via Processing Android Mode
  • Gradle build: SUCCESSFUL
  • Device: Physical Android device (not emulator)

:white_check_mark: Build status

Gradle completes without errors:

BUILD SUCCESSFUL in 1m 17s
27 actionable tasks: 27 executed

APK installs correctly.


:cross_mark: Runtime crash (Logcat)

App crashes immediately on launch with the following stack trace:

FATAL EXCEPTION: main
Process: processing.test.sketch_260201b, PID: 14911
java.lang.VerifyError: Rejecting class processing.a2d.PSurfaceAndroid2D
that attempts to sub-type erroneous class processing.core.PSurfaceNone
(declaration of 'processing.a2d.PSurfaceAndroid2D' appears in
/data/app/.../base.apk)

	at processing.a2d.PGraphicsAndroid2D.createSurface(PGraphicsAndroid2D.java:180)
	at processing.core.PApplet.initSurface(PApplet.java:538)
	at processing.android.PFragment.onCreateView(PFragment.java:149)
	at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2963)
	...
Caused by: java.lang.VerifyError: Verifier rejected class
processing.core.PSurfaceNone:

android.content.Context processing.core.PSurfaceNone.getContext()
failed to verify:

can't resolve returned type 'android.content.Context' or
'android.support.wearable.watchface.WatchFaceService'

(declaration of 'processing.core.PSurfaceNone' appears in base.apk)

:magnifying_glass_tilted_left: Key observations

  • Error points to:
    • PSurfaceAndroid2D
    • PSurfaceNone
  • Mentions an unresolved reference to:
android.support.wearable.watchface.WatchFaceService
  • I am not targeting Wear OS and do not reference wearable APIs in my sketch

:test_tube: What I’ve already verified

  • JDK 17 is working correctly
  • Gradle caches cleared
  • Android SDK reinstalled
  • Project compiles cleanly
  • Issue reproduces even with simple / example sketches

May be the same issue described here: https://github.com/processing/processing-android/issues/729

See the fix offered by ‘ajavamind’: GitHub - ajavamind/processing-android-410-api-15: Processing-android AndroidMode version 4.5 (version 410) modified for devices using API 15

Addendum:

I just checked Android Mode on MacOS with Processing 4.5.1 and it worked with a Samsung A8 device:

void setup() {
  fullScreen();
  background(209);
  fill(0, 255, 0);
  rect(200,200,400,400);
}

void draw() {  
}