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: https://github.com/libsdl-org/SDL/blob/main/docs/README-android.md 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.