I opened the project folder in CMD and typed this command: "./gradlew" build
But I have these errors. Please wrote what I can try. I don’t want to use Android Studio. It is too slow on my laptop. I want to use CMD and Sublime Text 4.
E:\_Projects\SDL\android\android-project>"./gradlew" build
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :app:configureNdkBuildDebug[arm64-v8a] FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:configureNdkBuildDebug[arm64-v8a]'.
> [CXX1429] error when building with ndkBuild using E:\_Projects\SDL\android\android-project\app\jni\Android.mk: C++ build system [configure] failed while executing:
@echo off
"E:\\AppData\\Android\\SDK\\ndk\\25.1.8937393\\ndk-build.cmd" ^
"NDK_PROJECT_PATH=null" ^
"APP_BUILD_SCRIPT=E:\\_Projects\\SDL\\android\\android-project\\app\\jni\\Android.mk" ^
"NDK_APPLICATION_MK=E:\\_Projects\\SDL\\android\\android-project\\app\\jni\\Application.mk" ^
"APP_ABI=arm64-v8a" ^
"NDK_ALL_ABIS=arm64-v8a" ^
"NDK_DEBUG=1" ^
"NDK_OUT=E:\\_Projects\\SDL\\android\\android-project\\app\\build\\intermediates\\cxx\\Debug\\29445a3u/obj" ^
"NDK_LIBS_OUT=E:\\_Projects\\SDL\\android\\android-project\\app\\build\\intermediates\\cxx\\Debug\\29445a3u/lib" ^
"APP_PLATFORM=android-19" ^
"APP_SHORT_COMMANDS=false" ^
"LOCAL_SHORT_COMMANDS=false" ^
-B ^
-n
from E:\_Projects\SDL\android\android-project\app
E:/AppData/Android/SDK/ndk/25.1.8937393/build/../build/core/build-binary.mk:586: Android NDK: Module main depends on undefined modules: SDL2
E:/AppData/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.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 12s
15 actionable tasks: 2 executed, 13 up-to-date
android-project is a project template. To create a buildable project you should use androidbuild.sh (you have to use bash or port it to batch file) script or perform the same actions manually. See SDL2/Android - SDL Wiki
You can also prebuild SDL as a library to skip source-copy-build step for future projects.
Thank! I see that the manual has a link to this step-by-step manual: SDL/docs/README-android.md at main · libsdl-org/SDL · GitHub I opened the SDL2 source code folder and I found the androidbuild.sh inside the build-scripts folder. I think I should to go to the the build-scripts folder and run the androidbuild.sh script from it. The manual says:
for example if you are in the build-scripts directory and want to create the testgles.c test, you’ll run:
cd /usr/src/SDL2/build/org.libsdl.testgles/
ant debug install # SDL <= 2.0.7
./gradlew installDebug # SDL >= 2.0.8
In my case I use SDL >= 2.0.8. So I should use ./gradlew installDebug. I see that the SDL-release-2.28.5 has only one gradlew file inside of SDL-release-2.28.5\android-project:
I try to go to the SDL-release-2.28.5\android-project folder and execute of this command "./gradlew" installDebug But I again get the same error as in the first message:
E:\_Projects\SDL\android\SDL-release-2.28.5\android-project>"./gradlew" installDebug
> Task :app:configureNdkBuildDebug[arm64-v8a] FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:configureNdkBuildDebug[arm64-v8a]'.
> [CXX1429] error when building with ndkBuild using E:\_Projects\SDL\android\SDL-release-2.28.5\android-project\app\jni\Android.mk: C++ build system [configure] failed while executing:
@echo off
"E:\\AppData\\Android\\SDK\\ndk\\25.1.8937393\\ndk-build.cmd" ^
"NDK_PROJECT_PATH=null" ^
"APP_BUILD_SCRIPT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\jni\\Android.mk" ^
"NDK_APPLICATION_MK=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\jni\\Application.mk" ^
"APP_ABI=arm64-v8a" ^
"NDK_ALL_ABIS=arm64-v8a" ^
"NDK_DEBUG=1" ^
"NDK_OUT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\build\\intermediates\\cxx\\Debug\\29445a3u/obj" ^
"NDK_LIBS_OUT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\build\\intermediates\\cxx\\Debug\\29445a3u/lib" ^
"APP_PLATFORM=android-19" ^
"APP_SHORT_COMMANDS=false" ^
"LOCAL_SHORT_COMMANDS=false" ^
-B ^
-n
from E:\_Projects\SDL\android\SDL-release-2.28.5\android-project\app
E:/AppData/Android/SDK/ndk/25.1.8937393/build/../build/core/build-binary.mk:586: Android NDK: Module main depends on undefined modules: SDL2
E:/AppData/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.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 11s
14 actionable tasks: 14 executed
Yes, because the test directory was generated. And I did not see any error messages.
I just follow the manual. It says:
Go to the build-scripts director. I did it.
Compile a sample app (calls ndk-build) with the command: ./androidbuild.sh org.libsdl.testgles ../test/testgles.c. I did it. The test directory was generated.
Go to the SDL2/build/org.libsdl.testgles and execute ./gradlew installDebug. But I didn’t find this directory. There is no the build directory in the root of the SDL folder.
Where to create the jni folder? Inside the SDL-release-2.28.5\android-project?
I created the empty jni folder inside SDL-release-2.28.5\android-project:
I copied the content of the SDL-release-2.28.5\src folder to the SDL-release-2.28.5\android-project\jni:
I go to the SDL-release-2.28.5\android-project folder and execute the "./gradlew" build command:
E:\_Projects\SDL\android\SDL-release-2.28.5\android-project>"./gradlew" build
> Task :app:configureNdkBuildDebug[arm64-v8a] FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:configureNdkBuildDebug[arm64-v8a]'.
> [CXX1429] error when building with ndkBuild using E:\_Projects\SDL\android\SDL-release-2.28.5\android-project\app\jni\Android.mk: C++ build system [configure] failed while executing:
@echo off
"E:\\AppData\\Android\\SDK\\ndk\\25.1.8937393\\ndk-build.cmd" ^
"NDK_PROJECT_PATH=null" ^
"APP_BUILD_SCRIPT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\jni\\Android.mk" ^
"NDK_APPLICATION_MK=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\jni\\Application.mk" ^
"APP_ABI=arm64-v8a" ^
"NDK_ALL_ABIS=arm64-v8a" ^
"NDK_DEBUG=1" ^
"NDK_OUT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\build\\intermediates\\cxx\\Debug\\29445a3u/obj" ^
"NDK_LIBS_OUT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\build\\intermediates\\cxx\\Debug\\29445a3u/lib" ^
"APP_PLATFORM=android-19" ^
"APP_SHORT_COMMANDS=false" ^
"LOCAL_SHORT_COMMANDS=false" ^
-B ^
-n
from E:\_Projects\SDL\android\SDL-release-2.28.5\android-project\app
E:/AppData/Android/SDK/ndk/25.1.8937393/build/../build/core/build-binary.mk:586: Android NDK: Module main depends on undefined modules: SDL2
E:/AppData/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.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1m 46s
15 actionable tasks: 2 executed, 13 up-to-date
I tried to execute this script again after coping source files to jni: "./androidbuild.sh" org.libsdl.testgles ../test/testgles.c
I ran this script in the android-project folder: "./gradlew" build. I have the same errors:
E:\_Projects\SDL\android\SDL-release-2.28.5\android-project>"./gradlew" build
> Task :app:compileDebugJavaWithJavac
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
> Task :app:configureNdkBuildDebug[arm64-v8a] FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:configureNdkBuildDebug[arm64-v8a]'.
> [CXX1429] error when building with ndkBuild using E:\_Projects\SDL\android\SDL-release-2.28.5\android-project\app\jni\Android.mk: C++ build system [configure] failed while executing:
@echo off
"E:\\AppData\\Android\\SDK\\ndk\\25.1.8937393\\ndk-build.cmd" ^
"NDK_PROJECT_PATH=null" ^
"APP_BUILD_SCRIPT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\jni\\Android.mk" ^
"NDK_APPLICATION_MK=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\jni\\Application.mk" ^
"APP_ABI=arm64-v8a" ^
"NDK_ALL_ABIS=arm64-v8a" ^
"NDK_DEBUG=1" ^
"NDK_OUT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\build\\intermediates\\cxx\\Debug\\29445a3u/obj" ^
"NDK_LIBS_OUT=E:\\_Projects\\SDL\\android\\SDL-release-2.28.5\\android-project\\app\\build\\intermediates\\cxx\\Debug\\29445a3u/lib" ^
"APP_PLATFORM=android-19" ^
"APP_SHORT_COMMANDS=false" ^
"LOCAL_SHORT_COMMANDS=false" ^
-B ^
-n
from E:\_Projects\SDL\android\SDL-release-2.28.5\android-project\app
E:/AppData/Android/SDK/ndk/25.1.8937393/build/../build/core/build-binary.mk:586: Android NDK: Module main depends on undefined modules: SDL2
E:/AppData/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.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 14s
16 actionable tasks: 2 executed, 14 up-to-date
Note. This manual works for Android. Except “Ninja” app that must be installed (and added to Path, I used one from Qt: C:\Qt\Tools\Ninja ) and manually changing of CMake version in the build.gradle script.
I use scrcpy to show an Android screen on Laptop to make screenshots. I connected a phone using USB.
@alisanDogn let’s try to build the SDL3 example and run it on Android. Let’s make the following steps to understand what step stops you:
Open CMD and execute this command: git clone https://github.com/Ravbug/sdl3-sample --depth=1 --recurse-submodules
That command will download the example and SDL3 source code. All requires 155 MB.
You will see the build.gradle file here:
You should copy it to this folder: sdl3-sample\SDL\android-project\app
Go to the sdl3-sample\SDL\android-project folder in CMD and execute this command: gradlew assembleDebug
Wait a few minutes for building. At first time it is very long - 13 minutes on my laptop. But next builds will be much faster. sdl3-sample requires 327 MB after building for Android.
APK-file will be created here: sdl3-sample\SDL\android-project\app\build\outputs\apk\debug
Yes, it must work. I have tried it right now. I recommend you to connect your phone with USB-cable. Execute this command: gradlew installDebug. The application will be installed on your device. It requires 38 seconds on my laptop. A source code of the example is here: sdl3-sample\src in the main.cpp file. I tried to change the background color to this color:
auto red = 255;
auto green = 50;
auto blue = 100;
SDL_SetRenderDrawColor(app->renderer, red, green, blue, SDL_ALPHA_OPAQUE);
I got an error like this: C:\Users\alisa\OneDrive\lasttest\sdl3-sample\SDL\android-project> ./gradlew assembleDebug
Starting a Gradle Daemon, 3 incompatible and 1 stopped Daemons could not be reused, use --status for details
<—<—<—<—<—<—<—<—<—<—<—<—<—<—<-<-<-<-<-<-
FAILURE: Build failed with an exception. > Evaluating> > > root> > root project