d_android 0.0.3

Helper programs, instructions, and bindings for using D on Android

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

This repository contains translated Android headers, helper programs, and build instructions.

For Users

To get started:

  1. Download the Android NDK. I have version 20 here, I believe it will work with anything past version 18. Set the environment variable NDK to its path.
  2. Download LDC, at least version 1.19. Make sure ldc2 is in your PATH.
  3. If you use dub, make sure you have at least version 1.18
  4. Build the runtime with ldc-build-runtime for each supported platform. See the android-setup.d for my notes. You can't run that program yet but you can easily follow along with the short, simple comments. It expects these results will be found in this same directory.
  5. Build your program for each supported platform. My android-dub-build can help with this.
  6. Copy the generated libs into your existing Android project's jniLibs folder. My android-dub-build will do this for you too if you pass it the directory.

On my box, for example, I can put a jni library in a project called "omg" like this:

$ NDK=/home/me/Android/ndk/android-ndk-r20/ /home/me/Android/d_android/android-dub-build /home/me/Android/omg/app/src/main/

If you use dub, make sure you set targetType = dynamicLibrary in your app's dub.json.

However, dub doesn't know how to do an Android link, so we will need to cheat by using a compiler wrapper.

Make sure my android-ldc is in your path as well as your real copy of ldc, configure it to point at your android NDK by setting an environment variable and then:

dub build --compiler=android-ldc -a ARCH

There are a few different arches you need to build for. If you like, you can use my wrapper script too.


Will compile it for each Android architecture. If you give it a target directory, it will copy it into the jniLibs for you too.

Helper programs

Each helper program is a stand-alone D file, depending on nothing outside Phobos. Simply compile them with dmd file.d and then run them.


ldc supports compiling D code, the only trouble is you must use the linker from Android's NDK and build for the necessary platforms. If you have an existing build system you can do the same thing: compile for the arch, link with the ndk linker, repeat for all necessary arches.


java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "_tlsstart" referenced by means you forgot a void main() {} in your thing. It is never called, but is needed for a TLS hack.

Make sure your class is final if you use arsd.jni. Otherwise you will see mysterious crashes on Android.

Notes for future maintainers

0.1.1 2020-Apr-05
0.1.0 2020-Apr-02
0.0.5 2020-Jan-10
0.0.4 2020-Jan-10
0.0.3 2019-Dec-16
Show all 6 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 1 downloads this month

  • 72 downloads total

Short URL: