# How to build a SDL2 application for Android using command line

**URL:** <https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021>\
**Category:** SDL Development\
**Created:** [December 27, 2023, 1:00am UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021 "2023-12-27T01:00:17Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![alisanDogn](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alisanDogn](https://discourse.libsdl.org/u/alisanDogn)\
**Post date:** [April 29, 2024, 8:20pm UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/21 "2024-04-29T20:20:26Z")

</div>

> [@8Observer8](#):
>
> Sorry, no ideas. Try to ask on discord. Please, write here if you solve the problem.

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.

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [April 29, 2024, 8:22pm UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/22 "2024-04-29T20:22:17Z")

</div>

> [@alisanDogn](#):
>
> I already had a build.gradle file under android-project/app. I removed the build.gradle file I just copied.

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

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [April 30, 2024, 8:19am UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/23 "2024-04-30T08:19:17Z")

</div>

@alisanDogn what’s the news?

---

<div class="post-metadata">

**Author:** ![alisanDogn](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alisanDogn](https://discourse.libsdl.org/u/alisanDogn)\
**Post date:** [April 30, 2024, 8:52am UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/24 "2024-04-30T08:52:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![alisanDogn](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alisanDogn](https://discourse.libsdl.org/u/alisanDogn)\
**Post date:** [April 30, 2024, 9:19am UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/25 "2024-04-30T09:19:19Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![alisanDogn](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alisanDogn](https://discourse.libsdl.org/u/alisanDogn)\
**Post date:** [April 30, 2024, 9:19am UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/26 "2024-04-30T09:19:37Z")

</div>

![WhatsApp Image 2024-04-30 at 12.17.58_b63fc4ab](https://discourse.libsdl.org/uploads/default/original/2X/4/4a194c2ef8a5ba115dfb5c4064d892cb76ae8c07.jpeg)

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [April 30, 2024, 11:42am UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/27 "2024-04-30T11:42:24Z")

</div>

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](https://discourse.libsdl.org/t/my-step-by-step-guide-how-to-run-sdl3-app-on-web-with-webassembly-on-windows/50766) You don’t need to download this example again.

---

<div class="post-metadata">

**Author:** ![alisanDogn](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/a/dfb087/32.png) [@alisanDogn](https://discourse.libsdl.org/u/alisanDogn)\
**Post date:** [April 30, 2024, 5:33pm UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/28 "2024-04-30T17:33:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [April 30, 2024, 10:20pm UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/29 "2024-04-30T22:20:36Z")

</div>

My step by step guide: [How to run SDL3 app on Android from Windows](https://8observer8.github.io/guides/how-to-run-sdl3-app-on-android-from-windows/index.html)

---

<div class="post-metadata">

**Author:** ![8Observer8](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/8/bbe5ce/32.png) [@8Observer8](https://discourse.libsdl.org/u/8Observer8)\
**Post date:** [August 23, 2024, 2:23pm UTC](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021/30 "2024-08-23T14:23:13Z")

</div>

[Deploying SDL3 app on Android using SDL3-x.y.z.aar](https://discourse.libsdl.org/t/deploying-sdl3-app-on-android-using-sdl3-x-y-z-aar/53779)

[Previous page](https://discourse.libsdl.org/t/how-to-build-a-sdl2-application-for-android-using-command-line/48021.md?page=1)
