Existing sketches not working with new Android Version

After I upgraded Android Version to 11, I tried to run existing sketches (which run OK with the previous Android version). The sketches fail to run.
I performed an SDK update. This did not help.
Any suggestions?
Thanks
Mike
strong text

Hello @MPROCD ,

You can always try a fresh install or a reset. Proceed with caution!

I don’t often use Android Mode but wanted to test out recent versions.

My environment:

  • Windows 10
  • Processing 4.4.10
  • Android Mode for Processing 4.6.1
  • Android 15

While Processing is closed:

  1. Delete the contents of the preferences folder.
  2. Delete the android folder from the Sketchbook folder
  3. Delete AndroidMode folder from the mode folder in the Sketchbook folder

Start Processing and select the Sketchbook folder that you will be using.

I then installed Android mode and everything seemed to work as expected and was able to run sketches on my Android 15 phone.

I use a custom location for my Sketchbook folder and preferences:

I was able to create a sketch and run it on my Android 15 device.

Reference for custom preferences folder location::

Proceed with caution before deleting folders and do so at your own risk.
Ensure you have everything backed up.

What is your environment?
Can you share a minimal sketch that fails and I can try it on my setup.
If you do sort this out please share with details.

This is the Android related contents of my preferences.txt:

ANDROID_SDK=E:\AndroidSketchbook\android\sdk
JAVA_HOME=D:\Program_Portable\Processing-4.4.10\app\resources\jdk
PATH=D:\Program_Portable\Processing-4.4.10\app\resources\jdk\bin;E:\AndroidSketchbook\android\sdk\platform-tools;E:\AndroidSketchbook\android\sdk\cmdline-tools\latest;null
android.gradle_plugin=7.1.0
android.sdk.appcompat=1.6.0
android.sdk.ar=1.37.0
android.sdk.gvr=1.180.0
android.sdk.path=E:\AndroidSketchbook\android\sdk
android.sdk.play_services=18.0.0
android.sdk.target=33
android.sdk.target.wear=30
android.sdk.target.wear_arm=24
android.sdk.v4legacy=1.0.0
android.sdk.wear=2.9.0
...
sketchbook.path.four=E:\AndroidSketchbook
...

:)

Hello @MPROCD,

I had issues with a fresh install of Android mode and the latest SDK.

I installed Processing 4.5.3 and used an older SDK and it worked!

Older SDK had this:

Latest SDK download had this:

I had to modify the preferences.txt manually to add the SDK location:

There were issues trying to add it with the new preferences UI (User Interface) so I abandoned that approach.

At first glance it seems that the new SDK is missing the required base platforms/android-33 package and only contains platforms/android-33-ext*.

I rarely use Android mode and this is what I can share from a quick exploration.

:)

Further exploration suggests that this may be an issue here:

Replace this:

// Platform
// Matches platform packages by target SDK number, so it may match an ext package.
expr = xpath.compile("//remotePackage[starts-with(@path, \"platforms;\")" +
                     "and contains(@path, '" + AndroidBuild.TARGET_SDK + "')]");

With this:

// Platform
// Require the exact base platform package:
expr = xpath.compile("//remotePackage[@path=\"platforms;android-" + AndroidBuild.TARGET_SDK + "\"" +
                     " and display-name=\"Android SDK Platform " + AndroidBuild.TARGET_SDK + "\"]");

I also wrote a small Processing sketch to test this by extracting the relevant selection logic code from SDKDownloader.java. The sketch showed that the current selector picks the Android SDK Platform 33-ext5, while the stricter selector picks the Android SDK Platform 33 package.

I am not posting the sketch and leave that as an exercise for enthusiasts!

It looks like changes in the Android SDK repository may be the issue: the repository now returns an SDK Extension package before the base platform package. This is the case even in an older Processing version from which I borrowed the base platform package.

That was fun!

See also:
Android Mode Compiler, problem not solved yet

*** UPDATE ***

Hello folks!

I did a fresh install of Processing 4.5.2 for Windows to test Android Mode.

My environment:

  • Windows 10
  • Processing 4.5.2
  • Android Mode for Processing 4.6.1
  • Android 15 on a MotoG

Make sure you have a backup of your files before proceeding!
You are responsible for this!

While Processing is closed:

  • Delete the contents of the preferences folder.
  • Delete the android folder from the Sketchbook folder
  • Delete AndroidMode folder from the mode folder in the Sketchbook folder

Contents of preferences folder:

The SDK install first installed:

  • android-33-ext5 folder

When building the first sketch it then installed (this was shown in console):

  • android-33 folder

I then deleted the android-33-ext5 folder and it was still able to build and run on my Android phone with just the android-33 folder.

I did add the SDK folder location to the preferences as well otherwise I was prompted with each run to install or locate.

I made several efforts to be thorough testing this before and can’t comment on why this did not work at that time.
I saved a backup of the working android folder for future.

I will update if I have anything new to add.
An older install did NOT work but I deleted that in my cleanup efforts and can’t examine that.
I learned a lot along the way!

I will try this on a W11 machine when I get the chance.

:)