How to build a SDL2 application for Android using command line

I already had a build.gradle file under android-project/app. I removed the build.gradle file I just copied. and ran this command:./gradlew assembleDebug. It is currently performing a download: “Install NDK (Side by side) 25.1.8937393 v.25.1.8937393”. I will share the results here.

Sorry, I forgot to write that you should replace the old build.gradle with a new one.

@alisanDogn what’s the news?

After that I got an error like this:> Task :app:configureNdkBuildDebug[arm64-v8a] FAILEDm64-v8a]

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:app:configureNdkBuildDebug[arm64-v8a]’.

[CXX1429] error when building with ndkBuild using C:\Users\alisa\OneDrive\lasttest\sdl3-sample\SDL\android-project\app\jni\Android.mk: C++ build system [configure] failed while executing:
@echo off
“C:\Users\alisa\AppData\Local\Android\Sdk\ndk\25.1.8937393\ndk-build.cmd” ^
“NDK_PROJECT_PATH=null” ^
“APP_BUILD_SCRIPT=C:\Users\alisa\OneDrive\lasttest\sdl3-sample\SDL\android-project\app\jni\Android.mk” ^
“NDK_APPLICATION_MK=C:\Users\alisa\OneDrive\lasttest\sdl3-sample\SDL\android-project\app\jni\Application.mk” ^
“APP_ABI=arm64-v8a” ^
“NDK_ALL_ABIS=arm64-v8a” ^
“NDK_DEBUG=1” ^
"NDK_OUT=C:\Users\alisa\OneDrive\lasttest\sdl3-sample\SDL\android-project\app\build\intermediates\cxx\Debug\29445a3u/obj " ^
"NDK_LIBS_OUT=C:\Users\alisa\OneDrive\lasttest\sdl3-sample\SDL\android-project\app\build\intermediates\cxx\Debug\29445a3u/lib " ^
“APP_PLATFORM=android-19” ^
“APP_SHORT_COMMANDS=false” ^
“LOCAL_SHORT_COMMANDS=false” ^
-B^
-n
from C:\Users\alisa\OneDrive\lasttest\sdl3-sample\SDL\android-project\app
C:/Users/alisa/AppData/Local/Android/Sdk/ndk/25.1.8937393/build/…/build/core/build-binary.mk:586: Android NDK: Module main depends on undefined modules: SDL3

C:/Users/alisa/AppData/Local/Android/Sdk/ndk/25.1.8937393/build/…/build/core/build-binary.mk:599: *** Android NDK: Note that old versions of ndk -build silently ignored this error case. If your project worked on those versions, the missing libraries were not needed and you can remove those dependencies from the module to fix your build. Alternatively, set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies. . Stop.

@8Observer8 , thank you very much. I deleted the build.gradle under android-project/app and moved the build gradle in the root directory to android-project/app. And first I ran this command: ./gradlew assembleDebug. This worked. And then I plugged the USB cable into the phone. I ran this command: ./gradlew installDebug After a few USB settings on the phone, I installed the apk on my phone.

Thank you very much again. I have been working on this for a long time.

I’m very glad to see it! You already has the example that could be built to Web with WebAssembly. Could you, please, to test my step by step guid: How to run SDL3 app on Web with WebAssembly on Windows You don’t need to download this example again.

Unfortunately I’m very busy right now. I have other jobs besides software. But rest assured, I will try this when I am free.

1 Like

My step by step guide: How to run SDL3 app on Android from Windows

Deploying SDL3 app on Android using SDL3-x.y.z.aar