SDL2 Android build environment not working after "upgrade"

I develop my app for Windows, Linux and Android, using NDK in Android, of course. I am no expert in the Android IDE, and primarily use other IDE, and jus tuse Android Studio for compiling. I hate gradle so far, and find it extreemely anoying.

I spent many days or weeks to get SDL, SDL_image, SDL_mixer, SDL_net, SDL_ttf (and then ImGui) to work together with an application which uses OpenGL. Since then, everything has worked great until I decided to try “upgrading” Android Studio to be compatible with Google requirements.

I have been using the SDL2 gradle build files which come with SDL2
I have compared some of my SDL2 Android gradle build files, which are a couple of years old, to the newest ones, and find hardly any difference. Just a version number here and there so far.

After the upgrade, I am getting the following error now:

A problem occurred configuring project ‘:app’.

Could not create task ‘:app:mergeDebugAssets’.
Cannot use @TaskAction annotation on method IncrementalTask.taskAction$gradle_core() because interface org.gradle.api.tasks.incremental.IncrementalTaskInputs is not a valid parameter to an action method.

which refers to these lines in build.gradle

applicationVariants.all { variant ->
    tasks["merge${variant.name.capitalize()}Assets"]
        .dependsOn("externalNativeBuild${variant.name.capitalize()}")
}

I see the code in the newest released SDL’s build.gradle is identical to mine/this, and I cannot for nothing figure out what is causing this error message.
Besides the above error, Android Studio outputs about 2000 lines of this kind of junk:

  • Exception is:
    org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ‘:app’.
    at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:84)
    at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:77)
    ||at com.android.build.gradle.AbstractAppExtension.addVariant(AbstractAppExtension.kt:64)|
    |—|—|
    ||at com.android.build.gradle.internal.ApiObjectFactory.create(ApiObjectFactory.java:121)|
    ||… 204 more|
    …245 more
    …more and more…

This is the output when running gradlew from command line:

gradlew --warning-mode all --info --scan
Initialized native services in: C:\Users\Ingvar.gradle\native
Initialized jansi services in: C:\Users\Ingvar.gradle\native
Received JVM installation metadata from ‘C:\Program Files\Java\jdk-23’: {JAVA_HOME=C:\Program Files\Java\jdk-23, JAVA_VERSION=23.0.1, JAVA_VENDOR=Oracle Corporation, RUNTIME_NAME=Java™ SE Runtime Environment, RUNTIME_VERSION=23.0.1+11-39, VM_NAME=Java HotSpot™ 64-Bit Server VM, VM_VERSION=23.0.1+11-39, VM_VENDOR=Oracle Corporation, OS_ARCH=amd64}
The client will now receive all logging from the daemon (pid: 7824). The daemon log file: C:\Users\Ingvar.gradle\daemon\8.9\daemon-7824.out.log
Starting 4th build in daemon [uptime: 2 mins 19.851 secs, performance: 100%, GC rate: 0.00/s, heap usage: 0% of 1.5 GiB]
Using 8 worker leases.
Now considering [C:\Users\Ingvar\Desktop\Ingvar\programming\ThriveTown] as hierarchies to watch
Watching the file system is configured to be enabled if available
File system watching is active
Starting Build
Transforming develocity-gradle-plugin-3.17.5.jar (com.gradle:develocity-gradle-plugin:3.17.5) with InstrumentationAnalysisTransform
Transforming develocity-gradle-plugin-3.17.5.jar (com.gradle:develocity-gradle-plugin:3.17.5) with InstrumentationAnalysisTransform
Transforming develocity-gradle-plugin-3.17.5.jar (com.gradle:develocity-gradle-plugin:3.17.5) with MergeInstrumentationAnalysisTransform
Transforming develocity-gradle-plugin-3.17.5.jar (com.gradle:develocity-gradle-plugin:3.17.5) with ExternalDependencyInstrumentingArtifactTransform
Caching disabled for Groovy DSL script compilation (settings) because:
Build cache is disabled
Not worth caching.
Compiling settings file ‘[ROOT PROJECT PATH]\settings.gradle’ using BuildScriptTransformer.

FAILURE: Build failed with an exception.

  • What went wrong:
    BUG! exception in phase ‘semantic analysis’ in source unit ‘BuildScript’ Unsupported class file major version 67

Unsupported class file major version 67

  • Try:

Run with --stacktrace option to get the stack trace.
Run with --debug option to get more log output.
Get more help at https://help.gradle.org.

BUILD FAILED in 959ms
Watched directory hierarchies:

Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Use defined at Gradle, Inc. Terms of Use | Develocity. Do you accept these terms? [yes, no] yes

Gradle Terms of Use accepted.

Publishing build scan…
Build Scan® activation | Develocity

Does anyone have a clue where to begin? Have anyone been here and done that, and wouldn’t mind sharing a hint? Thank you so much!

Did you just upgrade Android Studio or did you also upgrade to a more recent version of SDL2?
If you so you might also want to copy the “project/app/src/main/java/org” folder from the recent SDL2 version to your project.

I only upgraded Android Studio. Perhaps I will have to upgrade the SDL version too. Not looking forward to it, as I had to fight a lot to get the other SDL libraries to compile together with it.