Cannot run sketch on old Android kitkat device, using Processing 4 IDE

This has become a ‘rabbit hole’ at 13 posts and has now gone full circle back to post 1. Reading this is probably a waste of time. I am starting a new topic with a different approach. “What requirements for Processing 4 and Android 4.4 KitKat?”.

I am here because I am no expert. Several years ago, using a MacBook Pro (Intel), I wrote a game using Processing v3 and it works on a Samsung kitkat (v4.4) device. I now need to make some changes that I have written and tested on a Mac ARM M2 mini with newer Samsung Android 12 device. It works.
I tried to install from the IDE v4+ to the old kitkat device and it gets there but then says unfortunately ‘sketch’ has stopped.
To eliminate my sketch I sent the Android Mode tutorial simple sketch from the Processing website. Same problem. That suggests to me that it is the v4 IDE or the Android Mode that is not now compatible. I did download an earlier Android Mode and placed it in the Modes folder and I then could not even build the sketch. I reverted to IDE v 3.5.4 and the Android Mode-265. Will not build.
The Android SDK has the kitkat platform installed (if that is relevant, which I doubt for the simple test sketch).
Can somebody please advise on what the problem is and in simple terms, how to cure it and where and what to obtain to do so.

It might be helpful if you could post the error message.

I have been unable to recreate the exact final situation on a new day, except that the message on the Samsung device is as said, “Unfortunately sketch x has stopped”. SDK cannot be found and on auto downloading it could not be loaded and so Android Mode disabled.
The simple sketch…

void setup() {
  fullScreen();
  noStroke();
  fill(0);
}

void draw() {
  background(204);
  if (mousePressed) {
    if (mouseX < width/2) {
      rect(0, 0, width/2, height); // Left
    } else {
      rect(width/2, 0, width/2, height); // Right
    }
  }
}

I decided to separate IDE v4 from v3 and SDK which may have caused SDK problems, by putting v3,5,4 on the MacBook, leaving v4 on the M2 Mini.
I loaded Android Mode for v3. The IDE still asked for the SDK, which I had copied from the M2 Mini. The message was that the SDK could not be loaded and Android mode disabled.
I deleted the sdk and when the message came up that it could not be found, used the auto download and received the same result. It showed the platform as Android 11. When I looked back minutes later the sdk folder was renamed to temp, containing only .zip files.
I presume that I need an earlier SDK platform but the SDK does not have a GUI and I am not familiar with obtaining a platform via terminal.
My next step is to install Android Studio which I believe will have a usable SDK Manager.
If anybody can see anything wrong in the meantime I would be grateful for any guidance.
Edit: i.e. Should I be able to program for KitKat using the latest IDE and SDK?
Edit-1 I have done as said above and installed the SDK directly in Documents/Processing/Android.
I added platforms to the SDK for KitKat.
The SDK (Android Studio) is not found and when I locate it I get the message…
“Bad news… The Android SDK could not be loaded. The Android Mode will be disabled.”

I have reverted to IDE v4 and its auto downloaded SDK but on the MacBook.
Sent the sketch as shown in previous post to the KitKat device with the following ‘Failed to Build’ error.
Any guidance please. There is an EDIT at the end.

Build folder: /var/folders/f1/z0vj31vn7kn_b1vpxqcp6dmm0000gn/T/android11398107857969930383sketch

org.gradle.tooling.GradleConnectionException: Could not execute build using connection to Gradle distribution 'https://services.gradle.org/distributions/gradle-7.2-bin.zip'.

at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55)

at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)

at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:43)

at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:69)

at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)

at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)

at java.base/java.lang.Thread.run(Unknown Source)

at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46)

at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:83)

at processing.mode.android.AndroidBuild.gradleBuildPackage(AndroidBuild.java:328)

at processing.mode.android.AndroidBuild.build(AndroidBuild.java:225)

at processing.mode.android.AndroidMode.handleRunDevice(AndroidMode.java:294)

at processing.mode.android.AndroidEditor$17.run(AndroidEditor.java:421)

Caused by: org.gradle.launcher.daemon.client.DaemonConnectionException: The newly created daemon process has a different context than expected.

It won't be possible to reconnect to this daemon. Context mismatch:

Java home is different.

Wanted: DefaultDaemonContext[uid=null,javaHome=/Applications/Processing.app/Contents/runtime/Contents/Home,daemonRegistryDir=/Users/Donald/.gradle/daemon,pid=4362,idleTimeout=null,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.base/java.nio.charset=ALL-UNNAMED,--add-opens,java.base/java.net=ALL-UNNAMED,--add-opens,java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=GB,-Duser.language=en,-Duser.variant]

Actual: DefaultDaemonContext[uid=21a0bf05-b8f8-4119-b80b-e59665298c1b,javaHome=/Library/Java/JavaVirtualMachines/jdk-24.jdk/Contents/Home,daemonRegistryDir=/Users/Donald/.gradle/daemon,pid=5232,idleTimeout=10800000,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.base/java.nio.charset=ALL-UNNAMED,--add-opens,java.base/java.net=ALL-UNNAMED,--add-opens,java.base/java.util.concurrent.atomic=ALL-UNNAMED,-Xmx1536m,-Dfile.encoding=UTF-8,-Duser.country=GB,-Duser.language=en,-Duser.variant]

at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connectToDaemonWithId(DefaultDaemonConnector.java:258)

at org.gradle.launcher.daemon.client.DefaultDaemonConnector.doStartDaemon(DefaultDaemonConnector.java:227)

at org.gradle.launcher.daemon.client.DefaultDaemonConnector.startDaemon(DefaultDaemonConnector.java:216)

at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:138)

at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:144)

at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:98)

at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:44)

at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:30)

at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:60)

at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:37)

at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:222)

at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:148)

at org.gradle.tooling.internal.provider.DefaultConnection.getModel(DefaultConnection.java:202)

at org.gradle.tooling.internal.consumer.connection.CancellableModelBuilderBackedModelProducer.produceModel(CancellableModelBuilderBackedModelProducer.java:54)

at org.gradle.tooling.internal.consumer.connection.PluginClasspathInjectionSupportedCheckModelProducer.produceModel(PluginClasspathInjectionSupportedCheckModelProducer.java:38)

at org.gradle.tooling.internal.consumer.connection.AbstractConsumerConnection.run(AbstractConsumerConnection.java:64)

at org.gradle.tooling.internal.consumer.connection.ParameterValidatingConsumerConnection.run(ParameterValidatingConsumerConnection.java:49)

at org.gradle.tooling.internal.consumer.DefaultBuildLauncher$1.run(DefaultBuildLauncher.java:97)

at org.gradle.tooling.internal.consumer.DefaultBuildLauncher$1.run(DefaultBuildLauncher.java:89)

at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:143)

at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)

at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:61)

at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)

at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:67)

at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)

at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)

at java.base/java.lang.Thread.run(Unknown Source)
***********************

EDIT: Have reverted to M2 Mini IDE v4 SDK has platforms for KitKat that I copied from the above experiment.
Connected the new Samsung and it worked as before. Connected the old Samsung and there is no error from the IDE, The grey screen displays as it should and then disappears with the message on the device, ‘Unfortunately the sketch has stopped’.
I have run out of tests. Maybe simply copying each platform folder is not enough.

I’m a long time user of Android with macos and have multiple Samsung devices which I have been able to use in the past. I recently upgraded to Processing version 4.4.1 on a Mac mini M2 and am getting the same error message that you posted running the demo code shown above. We may need to post a bug report; needs more study. Sorry that I can’t be more helpful at this time.

Running v3.5.4 on MacBook Pro with Big Sur ought to work as it used to, but doesn’t. The only difference seems to be the SDK. There seems to be no way to install an old version; that I know of. Perhaps somebody knows how to in order to eliminate that.
After all, had I left the computer as it was in 2023, it would surely work now.
Thank you for your input svan.

For whatever it’s worth, I was able to run a simple Android demo using Processing version 4.3. On my system the problem seems to be with version 4.4.1. I had no luck using Processing 3.5.4.

Thanks svan. I was working some weeks ago with v4.3.4 getting nowhere as said, and a notice suggested there was a new version presumably v4.4.1 which caused bad troubles so I reverted to v4.3.4 which apart from all the above posts is where I am in the belief that it should work and be backward compatible.
The hole in my knowledge is whether v4.3.4 should permit the correct download of Android Mode that is backward compatible, and an SDK that also works. Can it be installed manually because auto download always gets the latest. I am expecting somehow to be able to recreate the setup I had in 2022-23 which where I believe I started with v3.5 and I upgraded to v4.0.1. I was not aware that Android Mode also had a version number so have no info.
Surely somebody knows what is required to work with KitKat (SDK and Android Mode) and whether they can be installed manually rather than auto downloaded.

Are you aware that there is a folder in Documents/Processing called ‘modes’ and that inside there is a folder called ‘AndroidMode’? By renaming that folder to something like ‘AndroidMode_orig’ it is possible to insert another version of AndroidMode. I used to have to download a custom version that I found online to run older Android devices and substitute it as the active AndroidMode. Currently I am unable to recall where I got that download, but will post it if I find it. I also have a folder of multiple older AndroidMode versions, but have no idea which one you need or even how to get the version number. You are correct that there are multiple versions. When Processing updates were infrequent a workable AndroidMode would last a long time, but now that updates are coming more frequently it’s hard to keep up. The current editor automatically downloads the most recent version of AndroidMode so it is important to keep the older ones that work. There is no code repository of older AndroidModes that I am aware of.

Addendum:
This is the modified version that I used; it may or may not work for you.

Thank you very much svan,
I have now downloaded what you supplied and will try it. Meanwhile, as you have suggested, I have searched and also found the following:
Release Android Mode 0251 · processing/processing-android · GitHub
That has given me 251 which I will also try in the folder you suggest. It says it is compatible with Processing v3+
I will continue searching and trying. Thanks again.
EDIT: I just found this but don’t know if simply copying a downloaded sdk into the Processing/Android folder is enough.
SDK Archives | Android Developers

I am using on MacBook Pro OSX Big Sur, Processing v3.5.4 with Android Mode for v3+ (installed by Processing) and SDK for KitKat and also the latest platforms as downloaded by Android Studio into Processing/Android/SDK. The first failure was because there was no ‘tools’ folder in SDK. An empty ‘tools’ folder solved that and the SDK was recognised.
I sent the simple sketch shown in a previous post to Samsung GT-N5110 KitKat (Android 4.4) and received the following error, repeated too many times to post here, followed by a lot more of other incomprehensible red stuff.
Hopefully this will be enough to give the required clue to a helpful ‘Sherlock’.
Any advice please (remembering I am no expert).

Build failed.* What went wrong:
Execution failed for task ‘:app:checkDebugAarMetadata’.

Multiple task action failures occurred:
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (33) specified in a
dependency’s AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module’s compileSdkVersion (android-30).
Dependency: androidx.appcompat:appcompat-resources:1.6.0.
AAR metadata file: /Users/Donald/.gradle/caches/transforms-3/1c38851291cea6e63842c3c8449776a7/transformed/jetified-appcompat-resources-1.6.0/META-INF/com/android/build/gradle/aar-metadata.properties.
A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
The minCompileSdk (33) specified in a
dependency’s AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module’s compileSdkVersion (android-30).
Dependency: androidx.appcompat:appcompat:1.6.0.
AAR metadata file: /Users/Donald/.gradle/caches/transforms-3/2f207acfa8d4d5b0169b5dc56939ac86/transformed/appcompat-1.6.0/META-INF/com/android/build/gradle/aar-metadata.properties.

Do you have Android Mode for Processing 3 installed? 3.5.4 now works on my system. Under Tools menu on menubar, Add Tool…
am

I used v3.5.4 on the MacBook Pro to install Android Mode in the normal way, using ‘Manage Modes’ where it offered…
“Android Mode for Processing 3|This mode lets you use Processing to create Android apps”
As I said, The first attempt failed with a message that Android Mode was missing ‘tools’. I looked at the install on my M2 and it had an empty ‘tools’ folder, so I added an empty ‘tools’ folder to the Android Mode folder on the Macbook, v3.5.4. Sent the simple program and received the error shown above.
EDIT: I reinstalled v3.5.4 and from the ‘Welcome to Processing 3’ flashscreen, to be sure I had not skipped anything, I even had it create a new sketchbook folder. The IDE gave a message…
‘sketchbookCallback() could not be found.’ Probably not relevant but it is yet another anomalie.


EDIT-1: I have started from scratch again, installed v.3.5.4. Used ‘Add Mode’ to add Android Mode for v3 as above. It is selectable from the IDE top right mode selection for the current sketch. I noticed that there is no Android Mode folder under Processing folder. Sent same sketch to Samsung… It starts to build with the following white message followed by the red error message in my previous post.


/schemas.android.com/repository/android/common/01

Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01

Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/04 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}api-level>

Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01

Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01

Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/04 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01

unexpected element (uri:"", local:"extension-level"). Expected elements are <{}codename>,<{}api-level>

unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}api-level>

> Task :app:preBuild UP-TO-DATE

> Task :app:preDebugBuild UP-TO-DATE

> Task :app:compileDebugAidl NO-SOURCE

> Task :app:compileDebugRenderscript NO-SOURCE

> Task :app:generateDebugBuildConfig

> Task :app:javaPreCompileDebug

> Task :app:generateDebugResValues

> Task :app:generateDebugResources

> Task :app:checkDebugAarMetadata FAILED

> Task :app:mergeDebugResources

I’m not sure that this is sufficient. Under the Tools menubar item in Android Studio you should be able to see what SDK’s are installed by using the SDK Manager menuItem. Under ‘SDK Platforms’ see if Kit-Kat is installed:
kkat

Under ‘SDK Tools’ you should be able to install tools:
tools

@enonod

OK.. I think I was wrong … in the android mode files the minimum sdk requirement seems to be set at 17 (for basic apps) and kitkat is19 so it should be OK.

Totally messed up my install with the newest versions of android mode and processing itself, so reverted to my previous versions. I was on Processing 4.0.1 so I went back there, and found that the latest Android Mode 4.6.1 seems to work with it. I will try all the other Processing versions too at some time.

No idea how this would affect your problem with an old Galaxy … unless I can find one to borrow. It’s an interesting problem.

An idea to help diagnose … if you can install your app but it crashes when it tries to run saying Unfortunately sketch x has stopped you might be able to get some error feedback using Android Studio. Your phone should appear in Android Studio when you plug it in and automatically get selected. Run the app on your phone and the ‘log’ should churn out loads of messages … the ones you need will be the red text. If you can do that and post that error here, that might give us a clue.

1 Like

AndroidMode is in Documents/Processing/modes folder. Try running your code in AndroidStudio as suggested above.

@shedMusic
Again thanks for your time.
I know nothing about Android studio, I only used it to get SDK and place it where I wanted and then add platforms because I could not find details on doing it from cmdline.
I simply attempted to point Processing to that SDK folder when propmpted.
I did not have my project in Studio so it does not recognise the Samsung tablet, why would it under those circumstances? I am afraid that ‘rabbit hole’ will be off-limits for me.

I am unable to find a Processing 4.0.1 which is maybe what I used when I left the project and wiped the disk. Any zip versions I have found (not 4.0.1) on various Githubs have provided Processing.app not .dmg file, and so no installation, simply opens IDE 3.5.4 or more recent version 4’s
I have a vague memory that during the game project I upgraded to 4.0.1 and it was working but I attempted the next upgrade 4.1x and failed so reverted to 4.0.1

I have downloaded a file ‘Processing4-processing-1286-4.0.1.zip’, dated Aug. 2022. That is an Android Mode file. Some of my sketches date from 2022/23.
I cannot find any other versions other than for Processing 3 which I think is another ‘rabbit hole’. I need what is known to work and start from there. Perhaps you know where those you tested can be downloaded? There is a Github depository that lists the versions inc. 4.0.1 but seems only to show the change notes, not downloads.
Releases · processing/processing-android (github.com)

Releases · processing/processing4 · GitHub

@svan
Thank you for your time on this. I agree, I did have a tools folder on one of the many attempts and it contained sdkmanager. I tried to run it and all it did was open something like a terminal window, but this time white, showed a few messages and then said finished. I could not type anything. It did not get me any further by it being there.
There was no GUI for the sdkmanager which there used to be and I did not know what to type in normal terminal to use the manager anyway, so doomed from the start. I never had to do anything like this in the past, just write code, test, debug and send to tablet. I did not have to mess with anything else.
The sdk was downloaded by Processing and that was that. Hence my lack of the innards of all this. After all, Processing was originally meant for artists etc. who would have no knowledge either.
I did download platform 19 for KitKat and the folder is there.

@svan
I have no idea how to use Studio other than download the sdk. I have never used it as an IDE and it looks like a ‘rabbit hole’ and is probably a lot worse. Not something I could learn in short order.

I understand what you’re saying about the complexity of AndroidStudio, but I’m afraid you’ll need it to get everything setup correctly for Processing. I will be happy to walk you through using the SDK manager step by step if it will help. You don’t have to learn how to write source code for AS if you don’t want to, but learning to use the SDK Manager is no biggie in my opinion and something the average user should be able to do. I believe that you’re having trouble using an old Android device because things are not setup correctly. Furthermore, the Processing IDE changes more frequently these days and sometimes it’s difficult to keep up.