├── README.md ├── Setting_D_SDL ├── README.md └── sample.d ├── jni.d ├── log.d └── sample.d /README.md: -------------------------------------------------------------------------------- 1 | # D-Lang-on-Android 2 | 3 | This repository was created because there was information mismatches when looking to the D-Lang official wiki to [Build D For Android](https://wiki.dlang.org/Build_D_for_Android) 4 | 5 | The main differences is that I show how to get the official LDC build for your environment, how to set your variables on Linux and I discovered one problem that was missing a /lib after the lib-dirs in ldc2.conf 6 | 7 | # Install Android Studio and get NDK 8 | This is a very simple tutorial on how to do it as it has an infinitude of tutorials on how to get NDK for android 9 | Get Android Studio at https://developer.android.com/studio 10 | Finish installing it 11 | Go into the top right of your Android Studio IDE (taskbar) and search for `SDK Manager` 12 | Install the target SDK, currently the newest one is Android 10(Q), it is on "SDK Platforms" Selection 13 | Beside "SDK Platforms", it has "SDK Tools", click on it and select NDK, Android SDK Tools, Android SDK Platform-Tools, Android SDK Build-Tools then click on OK 14 | On the Top of the window, it has where SDK is located, you can always check it again for reference 15 | After that, just remember where your ndk is installed 16 | 17 | ## Installing LDC on Linux 18 | For installing LDC on Linux, I do not recommend getting it from the repository, instead, go to Dlang official installation website: 19 | [D-Lang Official Install Website](https://dlang.org/install.html) 20 | Then, get the D-Lang official installation script (install.sh) -> Direct link [D-Lang Install Script](https://dlang.org/install.sh) 21 | After that, open the Bash and: 22 | - chmod +x ./install.sh 23 | - ./install.sh ldc 24 | Executing those commands will install it in your /home/currentUser/dlang (~/dlang) 25 | If you try to execute than ldc2(the current version), you will see that it is not available, the install script actually comes with -a parameter that 26 | lets you "activate"(Actually export important variables to your path), but for some reason, my linux is not exports command is not saving those variables. 27 | So what we'll do is simply: 28 | - Go to ~/dlang/ldc(currentVersion) 29 | - Open activate with your favorite text editor 30 | - You will find the following lines in your text editor 31 | ```sh 32 | deactivate() { 33 | export PATH="$_OLD_D_PATH" 34 | export LIBRARY_PATH="$_OLD_D_LIBRARY_PATH" 35 | export LD_LIBRARY_PATH="$_OLD_D_LD_LIBRARY_PATH" 36 | unset _OLD_D_LIBRARY_PATH 37 | unset _OLD_D_LD_LIBRARY_PATH 38 | unset DMD 39 | unset DC 40 | export PS1="$_OLD_D_PS1" 41 | unset _OLD_D_PATH 42 | unset _OLD_D_PS1 43 | unset -f deactivate 44 | } 45 | 46 | if [ -v _OLD_D_PATH ] ; then deactivate; fi 47 | _OLD_D_PATH="${PATH:-}" 48 | _OLD_D_LIBRARY_PATH="${LIBRARY_PATH:-}" 49 | _OLD_D_LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-}" 50 | export LIBRARY_PATH="/home/hipreme/dlang/ldc-1.22.0/lib${LIBRARY_PATH:+:}${LIBRARY_PATH:-}" 51 | export LD_LIBRARY_PATH="/home/hipreme/dlang/ldc-1.22.0/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}" 52 | _OLD_D_PATH="${PATH:-}" 53 | _OLD_D_PS1="${PS1:-}" 54 | export PS1="(ldc-1.22.0)${PS1:-}" 55 | export PATH="/home/hipreme/dlang/ldc-1.22.0/bin${PATH:+:}${PATH:-}" 56 | export DMD=ldmd2 57 | export DC=ldc2 58 | ``` 59 | The important lines are those with `export` after the `if [ -v _OLD_D_PATH ]` 60 | Showing it easier as: 61 | ```sh 62 | export LIBRARY_PATH="/home/hipreme/dlang/ldc-1.22.0/lib${LIBRARY_PATH:+:}${LIBRARY_PATH:-}" 63 | export LD_LIBRARY_PATH="/home/hipreme/dlang/ldc-1.22.0/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}" 64 | export PS1="(ldc-1.22.0)${PS1:-}" 65 | export PATH="/home/hipreme/dlang/ldc-1.22.0/bin${PATH:+:}${PATH:-}" 66 | export DMD=ldmd2 67 | export DC=ldc2 68 | ``` 69 | Change /hipreme/ with your current username, save those lines on your clipboard and then: 70 | - Go to your $HOME 71 | - Edit .bashrc (you can just sudo vim ~/.bashrc if you wish) 72 | - On the top of your exports, copy every line that were described above 73 | - Now your PC should be able to execute ldc 74 | 75 | ## Getting Android lib for LDC 76 | Now you need to include an Android architecture lib on your LDC, to do that, go into the [LDC github repository](https://github.com/ldc-developers/ldc/) 77 | Go into the [releases](https://github.com/ldc-developers/ldc/releases/) 78 | Find for a release that matches your LDC version, as the time I'm writing this, my version is 1.22.0, so, it will have prefix like **ldc2-1.22.0-android** 79 | What you're searching for is the android architecture 64 (aarch64), so the version I needed to download is: *ldc2-1.22.0-android-aarch64.tar.xz* 80 | 81 | **IMPORTANT** 82 | > If your target architecture does not have a prebuilt binary(Those one that are in the LDC developers release assets), you will have to [build it yourself the Phobos and the DRuntime](https://wiki.dlang.org/Building_LDC_runtime_libraries) 83 | 84 | > Notice that inside your architecture target folder, you will see that there is a lib/ and other lib(commonly related to 32 bits), you can use that for 85 | distributing for another target, inside aarch64 there is a x86_64, you can set a configuration for targeting it too and in the binaries inside -gcc, search for x86_64 86 | 87 | After downloading it, it's time to setup your compiler to find its existence. 88 | 89 | ## Adding compilation command 90 | - Go to ~/dlang/ldc(yourVersionHere) 91 | - Extract your newly acquired file 92 | - Rename it to `lib-android__aarch64` 93 | 94 | - Go to ~/dlang/ldc(yourVersionHere)/etc/ 95 | - Open ldc2.conf 96 | - Append to the end of the file the following: 97 | ``` 98 | "aarch64-.*-linux-android": 99 | { 100 | switches = [ 101 | "-defaultlib=phobos2-ldc,druntime-ldc", 102 | "-link-defaultlib-shared=false", 103 | "-gcc=/home/hipreme/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang", 104 | "-linker=/home/hipreme/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/linux-x86_64/bin/ld" 105 | ]; 106 | lib-dirs = [ 107 | "%%ldcbinarypath%%/../lib-android_aarch64/lib", 108 | ]; 109 | rpath = ""; 110 | }; 111 | ``` 112 | - In the line of `-gcc=` you should put your Android NDK, mine was on that folder, but what you should search for is `toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang` 113 | 114 | > If you're compiling for Windows, your path will probably be something like 115 | >`"-gcc=C:/Users/Hipreme/AppData/Local/Android/Sdk/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/bin/aarch64-linux-android21-clang.cmd"` 116 | 117 | After that, download a sample d program from the official wiki: 118 | ```sh 119 | curl -L -O https://raw.githubusercontent.com/dlang/dmd/master/samples/sieve.d 120 | 121 | # Cross-compile & -link to ARMv7-A (on any host)(I'm not using this right now) 122 | #ldc2 -mtriple=armv7a--linux-androideabi sieve.d 123 | 124 | # Cross-compile & -link to AArch64 (on any host) 125 | ldc2 -mtriple=aarch64--linux-android sieve.d 126 | 127 | # Compile & link natively in Termux 128 | ldc2 sieve.d 129 | ``` 130 | If it compiles well, your LDC is correctly configured to start working with Android. 131 | 132 | Before going to the next part of this tutorial, I would like to increment that this architecture is used as a sample because this is my phone's 133 | respective architecture, if you wish to compile for any other architecture, take a look at [Cross Compiling with LDC](https://wiki.dlang.org/Cross-compiling_with_LDC) 134 | 135 | 136 | 137 | # Preparing your D module for Android 138 | After your first succesful try of compiling it to the Android architecture, you will actually need to do three things: 139 | 1. You will need to import the D module jni on the top of your file: `import jni`. The JNI module was not made by me, the file in this repository is 140 | a reference to the [Original Repository](https://github.com/Diewi/android) for mantaining compatibility 141 | 2. Create a file that you wish to export into Android. You will need to make your function to export as `extern(C)` and name it in the same convention as you 142 | would name a C function to be exported from NDK Java_packagename_ClassName_methodName(JNIEnv* env, jclass clazz) 143 | sample.d 144 | ```d 145 | import jni; 146 | import std.conv : to; 147 | import core.runtime : rt_init; 148 | import std.string; 149 | extern(C) jstring Java_my_long_package_name_ClassName_methodname(JNIEnv* env, jclass clazz, jstring stringArgReceivedFromJava) 150 | { 151 | rt_init(); 152 | const char* javaStringInCStyle = (*env).GetStringUTFChars(env, stringArgReceivedFromJava, null); 153 | string javaStringInDStyle = to!string(javaStringInCStyle); 154 | (*env).ReleaseStringUTFChars(env, stringArgReceivedFromJava, javaStringInCStyle); 155 | 156 | return (*env).NewUTFString(toStringz("Hello from D, myarg: "~javaStringInDStyle)); 157 | } 158 | void main(){} 159 | ``` 160 | 3. Compile it as a shared library, suppose you're targetting the Arm64 architecture, you would need to call: 161 | `ldc2 -mtriple=aarch64--linux-android --shared sample.d` 162 | This will output libsample.so, this file will be included in your Android project 163 | 164 | # Word of caution 165 | Always call rt_init, or it will probably cause the sigsegfault(5), using to!string didn't work until I called rt_init(); 166 | 167 | # Creating an Android Project 168 | By the time of this writing, in the Official D Wiki for Building to Android, the way to generate an apk is documented for using Ant, but this is long gone, 169 | there's little documentation on how to actually use it, and it would be useless for today's Android development, as everyone uses Gradle, there's little to 170 | know about gradle when managing an entire android project, and it can add many libs with simple commands, so we'll be using Android Studio 171 | - Open Android Studio 172 | - Go into "Start a new Android Studio project" 173 | - Select "Empty Activity" 174 | - Name your project(Suppose I named mine as Test with the package as com.hipreme.test) 175 | - Configure and click on Finish(I'm currently using min API 23) 176 | - Go into the left side of your window and set your view as "Project" 177 | Your folder structure must be like: 178 | ``` 179 | Test 180 | |--.gradle 181 | |--.idea 182 | |--app 183 | |--|--build 184 | |--|--libs 185 | |--|--src 186 | |--|--|--androidTest 187 | |--|--|--main 188 | |--|--|--test 189 | |--|--|.gitignore 190 | |--|--app.iml 191 | |--|--build.gradle 192 | |--|--proguard-rules.pro 193 | |--gradle 194 | |--.gitignore 195 | |--buid.gradle 196 | |--gradle.properties 197 | |--gradlew 198 | |--gradlew.bat 199 | |--local.properties 200 | |--settings.gradle 201 | |--Test.iml 202 | ``` 203 | And in the end there are: 204 | ``` 205 | |> External Libraries 206 | |> Scratches and Consoles 207 | ``` 208 | Open the folder Test/app/src/main and inside main, create a folder called `jniLibs`, this folder is **extremely important**, it is the default folder to 209 | put your shared libraries to be imported together with your .apk. If you wish to use other name for it, you will need to change your gradle file. 210 | For actually putting your libraries inside that folder, you will actually need to make directories for the target architectures, so, create inside it: 211 | - armeabi-v7a (For that, it is commonly used ldc2(version)-android-armv7a/lib 212 | - arm64-v8a (This is our target right now, ldc2(version)-android-aarch64/lib) 213 | - x86 (It is the lib32 for armv7a -> ldc2(version)-android-armv7a/lib686 214 | - x86_64 (It is the lib32 for the aarch64 -> ldc2(version)-android-aarch64/lib-x86_64 215 | For reference, check ndk abi guide from official android site: [Android ABI Guide](https://developer.android.com/ndk/guides/abis) 216 | Your new main structure must be: 217 | ``` 218 | main 219 | |--java 220 | |--jniLibs 221 | |--|--armeabi-v7a 222 | |--|--arm64-v8a 223 | |--|--x86 224 | |--|--x86_64 225 | |--res 226 | |--AndroidManifest.xml 227 | ``` 228 | After creating those folderes, you can actually move your shared library into one of those folders, as we're showing with aarch64, you should move 229 | your libsample.so into arm64-v8a 230 | With that, you should now be able to import your library into Android Studio by calling inside your java code, so, at main/ảva/your/long/package/name, create 231 | a new .java file, I'll create a Sample.java file: 232 | ```java 233 | package com.hipreme.Sample; 234 | public class Sample 235 | { 236 | static{ 237 | System.loadLibrary("sample"); 238 | } 239 | public static native String methodname(String stringArgReceivedFromJava); 240 | } 241 | ``` 242 | Now, you're able to call `Sample.methodname("hello")` from anywhere in your code and D will be called on that 243 | 244 | ## Some useful libraries 245 | - log is a library for calling functions for logging in android e.g: `__android_log_vprint` 246 | 247 | 248 | 249 | If you wish to setup SDL with D, the tutorial is on Setting_D_SDL 250 | -------------------------------------------------------------------------------- /Setting_D_SDL/README.md: -------------------------------------------------------------------------------- 1 | # SDL Project 2 | ## **Setup firstly your NDK and LDC before trying to setup your SDL Project** 3 | 4 | You need to get the project from libsdl, the current SDL Version is SDL2.0.12, get the source code from [libsdl](https://www.libsdl.org/download-2.0.php) 5 | - Click to download the SDL2-X.Y.Z.tar.gz 6 | - Extract those files 7 | - Import SDL2-X.Y.Z/android-project into Android Studio 8 | - Generate symbolic links inside SDL2-X.Y.Z/android-project/app/jni folder using 9 | ```sh 10 | ln -s SDL2-X.Y.Z SDL2 11 | ln -s SDL2_image-X.Y.Z SDL2_image 12 | ln -s SDL2_mixer-X.Y.Z SDL2_mixer 13 | ln -s SDL2_net-X.Y.Z SDL2_net 14 | ln -s SDL2_ttf-X.Y.Z SDL2_ttf 15 | ``` 16 | 17 | - Go into Android Studio Build/Rebuild Project 18 | Now your project should throw a gradlew error about `YourSourceHere.c', needed by...`, basically, this file is a placeholder for the android-project. 19 | ## If you were to make a C project 20 | > Go into app/jni/src/Android.mk, if you modify LOCAL_SRC_FILES := YourSourceHere.c to include the needed file, after that, Sync the gradle, build your project and 21 | it should be able to run. 22 | 23 | # As a D project 24 | Delete the folder app/jni/src, this folder is where it creates the libmain.so, while the app/jni/ folder contains an Android.mk that will compile your SDL 25 | library. 26 | With D, you will need to provide your own libmain.so. That will be the main entrance point for using SDL on that android Project. 27 | After that, you're setup for including your main function. 28 | - Find app/src/jniLibs 29 | - Create the target architecture folder (I'm current using arm64-v8a) 30 | 31 | ## D code 32 | - Download/clone bindbc-sdl and bindbc-loader 33 | > [BindBC-SDL](https://github.com/BindBC/bindbc-sdl) 34 | > [BindBC-Loader](https://github.com/BindBC/bindbc-loader) 35 | - Import it into your main module 36 | - Follow BindBC SDL tutorial 37 | You will have a main function, change your main function to the `extern(C)int SDL_main()`, this is the entrance point to SDL 38 | > Minimal example code below: 39 | ```d 40 | import bindbc.sdl; 41 | import std.string; 42 | import std.conv : to; 43 | import core.runtime : rt_init; 44 | import jni; 45 | import android; 46 | bool loadSDLLibs() 47 | { 48 | SDLSupport ret = loadSDL(); 49 | if(ret != sdlSupport) 50 | if(ret == SDLSupport.noLibrary) 51 | __android_log_print(android_LogPriority.ANDROID_LOG_ERROR, toStringz("Sample"), toStringz("SDL not found")); 52 | else if(ret == SDLSupport.badLibrary) 53 | __android_log_print(android_LogPriority.ANDROID_LOG_ERROR, toStringz("Sample"), toStringz("Current SDL version lower than the expected version")); 54 | } 55 | 56 | SDL_Window* gWindow = null; 57 | SDL_Surface* gScreenSurface = null; 58 | 59 | extern(C) int SDL_main() 60 | { 61 | rt_init(); 62 | loadSDLLibs(); 63 | const int winPos = SDL_WINDOWPOS_UNDEFINED; 64 | SDL_Rect gScreenRect = {0,0,320,240}; 65 | SDL_DisplayMode displayMode; 66 | if( SDL_GetCurrentDisplayMode( 0, &displayMode ) == 0 ) 67 | { 68 | gScreenRect.w = displayMode.w; 69 | gScreenRect.h = displayMode.h; 70 | } 71 | 72 | gWindow = SDL_CreateWindow(cast(char*)"Sample", winPos, winPos, gScreenRect.w, gScreenRect.h, 73 | SDL_WindowFlags.SDL_WINDOW_SHOWN | SDL_WindowFlags.SDL_WINDOW_OPENGL ); 74 | if(window == null) 75 | __android_log_print(android_LogPriority.ANDROID_LOG_ERROR, toStringz("Sample"), toStringz("Window could not open: "~ to!string(SDL_GetError())); 76 | gScreenSurface = SDL_GetWindowSurface(gWindow); 77 | SDL_FillRect(gScreenSurface, null, SDL_MapRGB(gScreenSurface.format, 0xff, 0xff, 0x00)); 78 | bool quit = false; 79 | 80 | while(!quit) 81 | { 82 | SDL_Event e; 83 | while(SDL_PollEvent(&e)) 84 | { 85 | switch(e.type) 86 | { 87 | case SDL_QUIT: 88 | quit = true; 89 | break; 90 | default:break; 91 | } 92 | } 93 | SDL_UpdateWindowSurface(gWindow); 94 | SDL_Delay(16); 95 | } 96 | 97 | SDL_DestroyWindow(gWindow); 98 | gWindow = null; 99 | SDL_Quit(); 100 | } 101 | ``` 102 | 103 | ## D compile 104 | - Compile your D code as a shared library called libmain.so 105 | > Usually using the command ldc2 --arch=aarch64--linux-android app.d --shared --of=libmain.so 106 | > **Don't forget to include important LIBs like liblog.so with the -L command** 107 | >> Usually located at $NDK_PATH/toolchains/llvm/prebuilt/(yourpcSO_x86_64)/sysroot/usr/lib/(yourarchitecture)/(androidNdkApiLevel)/ 108 | >>> There are other important libs but as we're using SDL2, they are already included in the libsdl.so output from app/jni/src/Android.mk 109 | - Copy that file to app/src/main/jniLibs/(architecture folder) 110 | - Connect your phone/setup your emulator and run 111 | -------------------------------------------------------------------------------- /Setting_D_SDL/sample.d: -------------------------------------------------------------------------------- 1 | import bindbc.sdl; 2 | import std.string; 3 | import std.conv : to; 4 | import core.runtime : rt_init; 5 | import jni; 6 | import android; 7 | bool loadSDLLibs() 8 | { 9 | SDLSupport ret = loadSDL(); 10 | if(ret != sdlSupport) 11 | if(ret == SDLSupport.noLibrary) 12 | __android_log_print(android_LogPriority.ANDROID_LOG_ERROR, toStringz("Sample"), toStringz("SDL not found")); 13 | else if(ret == SDLSupport.badLibrary) 14 | __android_log_print(android_LogPriority.ANDROID_LOG_ERROR, toStringz("Sample"), toStringz("Current SDL version lower than the expected version")); 15 | } 16 | 17 | SDL_Window* gWindow = null; 18 | SDL_Surface* gScreenSurface = null; 19 | 20 | extern(C) int SDL_main() 21 | { 22 | rt_init(); 23 | loadSDLLibs(); 24 | const int winPos = SDL_WINDOWPOS_UNDEFINED; 25 | SDL_Rect gScreenRect = {0,0,320,240}; 26 | SDL_DisplayMode displayMode; 27 | if( SDL_GetCurrentDisplayMode( 0, &displayMode ) == 0 ) 28 | { 29 | gScreenRect.w = displayMode.w; 30 | gScreenRect.h = displayMode.h; 31 | } 32 | 33 | gWindow = SDL_CreateWindow(cast(char*)"Sample", winPos, winPos, gScreenRect.w, gScreenRect.h, 34 | SDL_WindowFlags.SDL_WINDOW_SHOWN | SDL_WindowFlags.SDL_WINDOW_OPENGL ); 35 | if(window == null) 36 | __android_log_print(android_LogPriority.ANDROID_LOG_ERROR, toStringz("Sample"), toStringz("Window could not open: "~ to!string(SDL_GetError())); 37 | gScreenSurface = SDL_GetWindowSurface(gWindow); 38 | SDL_FillRect(gScreenSurface, null, SDL_MapRGB(gScreenSurface.format, 0xff, 0xff, 0x00)); 39 | bool quit = false; 40 | 41 | while(!quit) 42 | { 43 | SDL_Event e; 44 | while(SDL_PollEvent(&e)) 45 | { 46 | switch(e.type) 47 | { 48 | case SDL_QUIT: 49 | quit = true; 50 | break; 51 | default:break; 52 | } 53 | } 54 | SDL_UpdateWindowSurface(gWindow); 55 | SDL_Delay(16); 56 | } 57 | 58 | SDL_DestroyWindow(gWindow); 59 | gWindow = null; 60 | SDL_Quit(); 61 | } 62 | -------------------------------------------------------------------------------- /jni.d: -------------------------------------------------------------------------------- 1 | /* dstep -I/path/to/ndk-r9d/platforms/android-9/arch-x86/usr/include -I/path/to/ndk-r9d/toolchains/llvm-3.4/prebuilt/linux-x86/lib/clang/3.4/include /path/to/ndk-r9d/platforms/android-9/arch-x86/usr/include/jni.h -o jni.d*/ 2 | 3 | module jni; 4 | 5 | import core.stdc.stdarg; 6 | 7 | version (Android): 8 | extern (C): 9 | @system: 10 | nothrow: 11 | @nogc: 12 | 13 | alias ubyte jboolean; 14 | alias byte jbyte; 15 | alias ushort jchar; 16 | alias short jshort; 17 | alias int jint; 18 | alias long jlong; 19 | alias float jfloat; 20 | alias double jdouble; 21 | alias jint jsize; 22 | alias void* jobject; 23 | alias jobject jclass; 24 | alias jobject jstring; 25 | alias jobject jarray; 26 | alias jarray jobjectArray; 27 | alias jarray jbooleanArray; 28 | alias jarray jbyteArray; 29 | alias jarray jcharArray; 30 | alias jarray jshortArray; 31 | alias jarray jintArray; 32 | alias jarray jlongArray; 33 | alias jarray jfloatArray; 34 | alias jarray jdoubleArray; 35 | alias jobject jthrowable; 36 | alias jobject jweak; 37 | alias _jfieldID* jfieldID; 38 | alias _jmethodID* jmethodID; 39 | alias const(JNINativeInterface)* C_JNIEnv; 40 | alias const(JNINativeInterface)* JNIEnv; 41 | alias const(JNIInvokeInterface)* JavaVM; 42 | 43 | enum jobjectRefType 44 | { 45 | JNIInvalidRefType = 0, 46 | JNILocalRefType = 1, 47 | JNIGlobalRefType = 2, 48 | JNIWeakGlobalRefType = 3 49 | } 50 | 51 | enum JNI_FALSE = 0; 52 | enum JNI_TRUE = 1; 53 | enum JNI_VERSION_1_1 = 0x00010001; 54 | enum JNI_VERSION_1_2 = 0x00010002; 55 | enum JNI_VERSION_1_4 = 0x00010004; 56 | enum JNI_VERSION_1_6 = 0x00010006; 57 | enum JNI_OK = 0; 58 | enum JNI_ERR = -1; 59 | enum JNI_EDETACHED = -2; 60 | enum JNI_EVERSION = -3; 61 | enum JNI_COMMIT = 1; 62 | enum JNI_ABORT = 2; 63 | 64 | struct JNINativeMethod 65 | { 66 | const(char)* name; 67 | const(char)* signature; 68 | void* fnPtr; 69 | } 70 | 71 | struct JNINativeInterface 72 | { 73 | void* reserved0; 74 | void* reserved1; 75 | void* reserved2; 76 | void* reserved3; 77 | jint function(JNIEnv*) GetVersion; 78 | jclass function(JNIEnv*, const(char)*, jobject, const(jbyte)*, jsize) DefineClass; 79 | jclass function(JNIEnv*, const(char)*) FindClass; 80 | jmethodID function(JNIEnv*, jobject) FromReflectedMethod; 81 | jfieldID function(JNIEnv*, jobject) FromReflectedField; 82 | jobject function(JNIEnv*, jclass, jmethodID, jboolean) ToReflectedMethod; 83 | jclass function(JNIEnv*, jclass) GetSuperclass; 84 | jboolean function(JNIEnv*, jclass, jclass) IsAssignableFrom; 85 | jobject function(JNIEnv*, jclass, jfieldID, jboolean) ToReflectedField; 86 | jint function(JNIEnv*, jthrowable) Throw; 87 | jint function(JNIEnv*, jclass, const(char)*) ThrowNew; 88 | jthrowable function(JNIEnv*) ExceptionOccurred; 89 | void function(JNIEnv*) ExceptionDescribe; 90 | void function(JNIEnv*) ExceptionClear; 91 | void function(JNIEnv*, const(char)*) FatalError; 92 | jint function(JNIEnv*, jint) PushLocalFrame; 93 | jobject function(JNIEnv*, jobject) PopLocalFrame; 94 | jobject function(JNIEnv*, jobject) NewGlobalRef; 95 | void function(JNIEnv*, jobject) DeleteGlobalRef; 96 | void function(JNIEnv*, jobject) DeleteLocalRef; 97 | jboolean function(JNIEnv*, jobject, jobject) IsSameObject; 98 | jobject function(JNIEnv*, jobject) NewLocalRef; 99 | jint function(JNIEnv*, jint) EnsureLocalCapacity; 100 | jobject function(JNIEnv*, jclass) AllocObject; 101 | jobject function(JNIEnv*, jclass, jmethodID, ...) NewObject; 102 | jobject function(JNIEnv*, jclass, jmethodID, va_list) NewObjectV; 103 | jobject function(JNIEnv*, jclass, jmethodID, jvalue*) NewObjectA; 104 | jclass function(JNIEnv*, jobject) GetObjectClass; 105 | jboolean function(JNIEnv*, jobject, jclass) IsInstanceOf; 106 | jmethodID function(JNIEnv*, jclass, const(char)*, const(char)*) GetMethodID; 107 | jobject function(JNIEnv*, jobject, jmethodID, ...) CallObjectMethod; 108 | jobject function(JNIEnv*, jobject, jmethodID, va_list) CallObjectMethodV; 109 | jobject function(JNIEnv*, jobject, jmethodID, jvalue*) CallObjectMethodA; 110 | jboolean function(JNIEnv*, jobject, jmethodID, ...) CallBooleanMethod; 111 | jboolean function(JNIEnv*, jobject, jmethodID, va_list) CallBooleanMethodV; 112 | jboolean function(JNIEnv*, jobject, jmethodID, jvalue*) CallBooleanMethodA; 113 | jbyte function(JNIEnv*, jobject, jmethodID, ...) CallByteMethod; 114 | jbyte function(JNIEnv*, jobject, jmethodID, va_list) CallByteMethodV; 115 | jbyte function(JNIEnv*, jobject, jmethodID, jvalue*) CallByteMethodA; 116 | jchar function(JNIEnv*, jobject, jmethodID, ...) CallCharMethod; 117 | jchar function(JNIEnv*, jobject, jmethodID, va_list) CallCharMethodV; 118 | jchar function(JNIEnv*, jobject, jmethodID, jvalue*) CallCharMethodA; 119 | jshort function(JNIEnv*, jobject, jmethodID, ...) CallShortMethod; 120 | jshort function(JNIEnv*, jobject, jmethodID, va_list) CallShortMethodV; 121 | jshort function(JNIEnv*, jobject, jmethodID, jvalue*) CallShortMethodA; 122 | jint function(JNIEnv*, jobject, jmethodID, ...) CallIntMethod; 123 | jint function(JNIEnv*, jobject, jmethodID, va_list) CallIntMethodV; 124 | jint function(JNIEnv*, jobject, jmethodID, jvalue*) CallIntMethodA; 125 | jlong function(JNIEnv*, jobject, jmethodID, ...) CallLongMethod; 126 | jlong function(JNIEnv*, jobject, jmethodID, va_list) CallLongMethodV; 127 | jlong function(JNIEnv*, jobject, jmethodID, jvalue*) CallLongMethodA; 128 | jfloat function(JNIEnv*, jobject, jmethodID, ...) CallFloatMethod; 129 | jfloat function(JNIEnv*, jobject, jmethodID, va_list) CallFloatMethodV; 130 | jfloat function(JNIEnv*, jobject, jmethodID, jvalue*) CallFloatMethodA; 131 | jdouble function(JNIEnv*, jobject, jmethodID, ...) CallDoubleMethod; 132 | jdouble function(JNIEnv*, jobject, jmethodID, va_list) CallDoubleMethodV; 133 | jdouble function(JNIEnv*, jobject, jmethodID, jvalue*) CallDoubleMethodA; 134 | void function(JNIEnv*, jobject, jmethodID, ...) CallVoidMethod; 135 | void function(JNIEnv*, jobject, jmethodID, va_list) CallVoidMethodV; 136 | void function(JNIEnv*, jobject, jmethodID, jvalue*) CallVoidMethodA; 137 | jobject function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualObjectMethod; 138 | jobject function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualObjectMethodV; 139 | jobject function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualObjectMethodA; 140 | jboolean function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualBooleanMethod; 141 | jboolean function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualBooleanMethodV; 142 | jboolean function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualBooleanMethodA; 143 | jbyte function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualByteMethod; 144 | jbyte function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualByteMethodV; 145 | jbyte function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualByteMethodA; 146 | jchar function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualCharMethod; 147 | jchar function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualCharMethodV; 148 | jchar function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualCharMethodA; 149 | jshort function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualShortMethod; 150 | jshort function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualShortMethodV; 151 | jshort function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualShortMethodA; 152 | jint function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualIntMethod; 153 | jint function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualIntMethodV; 154 | jint function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualIntMethodA; 155 | jlong function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualLongMethod; 156 | jlong function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualLongMethodV; 157 | jlong function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualLongMethodA; 158 | jfloat function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualFloatMethod; 159 | jfloat function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualFloatMethodV; 160 | jfloat function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualFloatMethodA; 161 | jdouble function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualDoubleMethod; 162 | jdouble function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualDoubleMethodV; 163 | jdouble function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualDoubleMethodA; 164 | void function(JNIEnv*, jobject, jclass, jmethodID, ...) CallNonvirtualVoidMethod; 165 | void function(JNIEnv*, jobject, jclass, jmethodID, va_list) CallNonvirtualVoidMethodV; 166 | void function(JNIEnv*, jobject, jclass, jmethodID, jvalue*) CallNonvirtualVoidMethodA; 167 | jfieldID function(JNIEnv*, jclass, const(char)*, const(char)*) GetFieldID; 168 | jobject function(JNIEnv*, jobject, jfieldID) GetObjectField; 169 | jboolean function(JNIEnv*, jobject, jfieldID) GetBooleanField; 170 | jbyte function(JNIEnv*, jobject, jfieldID) GetByteField; 171 | jchar function(JNIEnv*, jobject, jfieldID) GetCharField; 172 | jshort function(JNIEnv*, jobject, jfieldID) GetShortField; 173 | jint function(JNIEnv*, jobject, jfieldID) GetIntField; 174 | jlong function(JNIEnv*, jobject, jfieldID) GetLongField; 175 | jfloat function(JNIEnv*, jobject, jfieldID) GetFloatField; 176 | jdouble function(JNIEnv*, jobject, jfieldID) GetDoubleField; 177 | void function(JNIEnv*, jobject, jfieldID, jobject) SetObjectField; 178 | void function(JNIEnv*, jobject, jfieldID, jboolean) SetBooleanField; 179 | void function(JNIEnv*, jobject, jfieldID, jbyte) SetByteField; 180 | void function(JNIEnv*, jobject, jfieldID, jchar) SetCharField; 181 | void function(JNIEnv*, jobject, jfieldID, jshort) SetShortField; 182 | void function(JNIEnv*, jobject, jfieldID, jint) SetIntField; 183 | void function(JNIEnv*, jobject, jfieldID, jlong) SetLongField; 184 | void function(JNIEnv*, jobject, jfieldID, jfloat) SetFloatField; 185 | void function(JNIEnv*, jobject, jfieldID, jdouble) SetDoubleField; 186 | jmethodID function(JNIEnv*, jclass, const(char)*, const(char)*) GetStaticMethodID; 187 | jobject function(JNIEnv*, jclass, jmethodID, ...) CallStaticObjectMethod; 188 | jobject function(JNIEnv*, jclass, jmethodID, va_list) CallStaticObjectMethodV; 189 | jobject function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticObjectMethodA; 190 | jboolean function(JNIEnv*, jclass, jmethodID, ...) CallStaticBooleanMethod; 191 | jboolean function(JNIEnv*, jclass, jmethodID, va_list) CallStaticBooleanMethodV; 192 | jboolean function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticBooleanMethodA; 193 | jbyte function(JNIEnv*, jclass, jmethodID, ...) CallStaticByteMethod; 194 | jbyte function(JNIEnv*, jclass, jmethodID, va_list) CallStaticByteMethodV; 195 | jbyte function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticByteMethodA; 196 | jchar function(JNIEnv*, jclass, jmethodID, ...) CallStaticCharMethod; 197 | jchar function(JNIEnv*, jclass, jmethodID, va_list) CallStaticCharMethodV; 198 | jchar function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticCharMethodA; 199 | jshort function(JNIEnv*, jclass, jmethodID, ...) CallStaticShortMethod; 200 | jshort function(JNIEnv*, jclass, jmethodID, va_list) CallStaticShortMethodV; 201 | jshort function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticShortMethodA; 202 | jint function(JNIEnv*, jclass, jmethodID, ...) CallStaticIntMethod; 203 | jint function(JNIEnv*, jclass, jmethodID, va_list) CallStaticIntMethodV; 204 | jint function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticIntMethodA; 205 | jlong function(JNIEnv*, jclass, jmethodID, ...) CallStaticLongMethod; 206 | jlong function(JNIEnv*, jclass, jmethodID, va_list) CallStaticLongMethodV; 207 | jlong function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticLongMethodA; 208 | jfloat function(JNIEnv*, jclass, jmethodID, ...) CallStaticFloatMethod; 209 | jfloat function(JNIEnv*, jclass, jmethodID, va_list) CallStaticFloatMethodV; 210 | jfloat function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticFloatMethodA; 211 | jdouble function(JNIEnv*, jclass, jmethodID, ...) CallStaticDoubleMethod; 212 | jdouble function(JNIEnv*, jclass, jmethodID, va_list) CallStaticDoubleMethodV; 213 | jdouble function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticDoubleMethodA; 214 | void function(JNIEnv*, jclass, jmethodID, ...) CallStaticVoidMethod; 215 | void function(JNIEnv*, jclass, jmethodID, va_list) CallStaticVoidMethodV; 216 | void function(JNIEnv*, jclass, jmethodID, jvalue*) CallStaticVoidMethodA; 217 | jfieldID function(JNIEnv*, jclass, const(char)*, const(char)*) GetStaticFieldID; 218 | jobject function(JNIEnv*, jclass, jfieldID) GetStaticObjectField; 219 | jboolean function(JNIEnv*, jclass, jfieldID) GetStaticBooleanField; 220 | jbyte function(JNIEnv*, jclass, jfieldID) GetStaticByteField; 221 | jchar function(JNIEnv*, jclass, jfieldID) GetStaticCharField; 222 | jshort function(JNIEnv*, jclass, jfieldID) GetStaticShortField; 223 | jint function(JNIEnv*, jclass, jfieldID) GetStaticIntField; 224 | jlong function(JNIEnv*, jclass, jfieldID) GetStaticLongField; 225 | jfloat function(JNIEnv*, jclass, jfieldID) GetStaticFloatField; 226 | jdouble function(JNIEnv*, jclass, jfieldID) GetStaticDoubleField; 227 | void function(JNIEnv*, jclass, jfieldID, jobject) SetStaticObjectField; 228 | void function(JNIEnv*, jclass, jfieldID, jboolean) SetStaticBooleanField; 229 | void function(JNIEnv*, jclass, jfieldID, jbyte) SetStaticByteField; 230 | void function(JNIEnv*, jclass, jfieldID, jchar) SetStaticCharField; 231 | void function(JNIEnv*, jclass, jfieldID, jshort) SetStaticShortField; 232 | void function(JNIEnv*, jclass, jfieldID, jint) SetStaticIntField; 233 | void function(JNIEnv*, jclass, jfieldID, jlong) SetStaticLongField; 234 | void function(JNIEnv*, jclass, jfieldID, jfloat) SetStaticFloatField; 235 | void function(JNIEnv*, jclass, jfieldID, jdouble) SetStaticDoubleField; 236 | jstring function(JNIEnv*, const(jchar)*, jsize) NewString; 237 | jsize function(JNIEnv*, jstring) GetStringLength; 238 | const(jchar)* function(JNIEnv*, jstring, jboolean*) GetStringChars; 239 | void function(JNIEnv*, jstring, const(jchar)*) ReleaseStringChars; 240 | jstring function(JNIEnv*, const(char)*) NewStringUTF; 241 | jsize function(JNIEnv*, jstring) GetStringUTFLength; 242 | const(char)* function(JNIEnv*, jstring, jboolean*) GetStringUTFChars; 243 | void function(JNIEnv*, jstring, const(char)*) ReleaseStringUTFChars; 244 | jsize function(JNIEnv*, jarray) GetArrayLength; 245 | jobjectArray function(JNIEnv*, jsize, jclass, jobject) NewObjectArray; 246 | jobject function(JNIEnv*, jobjectArray, jsize) GetObjectArrayElement; 247 | void function(JNIEnv*, jobjectArray, jsize, jobject) SetObjectArrayElement; 248 | jbooleanArray function(JNIEnv*, jsize) NewBooleanArray; 249 | jbyteArray function(JNIEnv*, jsize) NewByteArray; 250 | jcharArray function(JNIEnv*, jsize) NewCharArray; 251 | jshortArray function(JNIEnv*, jsize) NewShortArray; 252 | jintArray function(JNIEnv*, jsize) NewIntArray; 253 | jlongArray function(JNIEnv*, jsize) NewLongArray; 254 | jfloatArray function(JNIEnv*, jsize) NewFloatArray; 255 | jdoubleArray function(JNIEnv*, jsize) NewDoubleArray; 256 | jboolean* function(JNIEnv*, jbooleanArray, jboolean*) GetBooleanArrayElements; 257 | jbyte* function(JNIEnv*, jbyteArray, jboolean*) GetByteArrayElements; 258 | jchar* function(JNIEnv*, jcharArray, jboolean*) GetCharArrayElements; 259 | jshort* function(JNIEnv*, jshortArray, jboolean*) GetShortArrayElements; 260 | jint* function(JNIEnv*, jintArray, jboolean*) GetIntArrayElements; 261 | jlong* function(JNIEnv*, jlongArray, jboolean*) GetLongArrayElements; 262 | jfloat* function(JNIEnv*, jfloatArray, jboolean*) GetFloatArrayElements; 263 | jdouble* function(JNIEnv*, jdoubleArray, jboolean*) GetDoubleArrayElements; 264 | void function(JNIEnv*, jbooleanArray, jboolean*, jint) ReleaseBooleanArrayElements; 265 | void function(JNIEnv*, jbyteArray, jbyte*, jint) ReleaseByteArrayElements; 266 | void function(JNIEnv*, jcharArray, jchar*, jint) ReleaseCharArrayElements; 267 | void function(JNIEnv*, jshortArray, jshort*, jint) ReleaseShortArrayElements; 268 | void function(JNIEnv*, jintArray, jint*, jint) ReleaseIntArrayElements; 269 | void function(JNIEnv*, jlongArray, jlong*, jint) ReleaseLongArrayElements; 270 | void function(JNIEnv*, jfloatArray, jfloat*, jint) ReleaseFloatArrayElements; 271 | void function(JNIEnv*, jdoubleArray, jdouble*, jint) ReleaseDoubleArrayElements; 272 | void function(JNIEnv*, jbooleanArray, jsize, jsize, jboolean*) GetBooleanArrayRegion; 273 | void function(JNIEnv*, jbyteArray, jsize, jsize, jbyte*) GetByteArrayRegion; 274 | void function(JNIEnv*, jcharArray, jsize, jsize, jchar*) GetCharArrayRegion; 275 | void function(JNIEnv*, jshortArray, jsize, jsize, jshort*) GetShortArrayRegion; 276 | void function(JNIEnv*, jintArray, jsize, jsize, jint*) GetIntArrayRegion; 277 | void function(JNIEnv*, jlongArray, jsize, jsize, jlong*) GetLongArrayRegion; 278 | void function(JNIEnv*, jfloatArray, jsize, jsize, jfloat*) GetFloatArrayRegion; 279 | void function(JNIEnv*, jdoubleArray, jsize, jsize, jdouble*) GetDoubleArrayRegion; 280 | void function(JNIEnv*, jbooleanArray, jsize, jsize, const(jboolean)*) SetBooleanArrayRegion; 281 | void function(JNIEnv*, jbyteArray, jsize, jsize, const(jbyte)*) SetByteArrayRegion; 282 | void function(JNIEnv*, jcharArray, jsize, jsize, const(jchar)*) SetCharArrayRegion; 283 | void function(JNIEnv*, jshortArray, jsize, jsize, const(jshort)*) SetShortArrayRegion; 284 | void function(JNIEnv*, jintArray, jsize, jsize, const(jint)*) SetIntArrayRegion; 285 | void function(JNIEnv*, jlongArray, jsize, jsize, const(jlong)*) SetLongArrayRegion; 286 | void function(JNIEnv*, jfloatArray, jsize, jsize, const(jfloat)*) SetFloatArrayRegion; 287 | void function(JNIEnv*, jdoubleArray, jsize, jsize, const(jdouble)*) SetDoubleArrayRegion; 288 | jint function(JNIEnv*, jclass, const(JNINativeMethod)*, jint) RegisterNatives; 289 | jint function(JNIEnv*, jclass) UnregisterNatives; 290 | jint function(JNIEnv*, jobject) MonitorEnter; 291 | jint function(JNIEnv*, jobject) MonitorExit; 292 | jint function(JNIEnv*, JavaVM**) GetJavaVM; 293 | void function(JNIEnv*, jstring, jsize, jsize, jchar*) GetStringRegion; 294 | void function(JNIEnv*, jstring, jsize, jsize, char*) GetStringUTFRegion; 295 | void* function(JNIEnv*, jarray, jboolean*) GetPrimitiveArrayCritical; 296 | void function(JNIEnv*, jarray, void*, jint) ReleasePrimitiveArrayCritical; 297 | const(jchar)* function(JNIEnv*, jstring, jboolean*) GetStringCritical; 298 | void function(JNIEnv*, jstring, const(jchar)*) ReleaseStringCritical; 299 | jweak function(JNIEnv*, jobject) NewWeakGlobalRef; 300 | void function(JNIEnv*, jweak) DeleteWeakGlobalRef; 301 | jboolean function(JNIEnv*) ExceptionCheck; 302 | jobject function(JNIEnv*, void*, jlong) NewDirectByteBuffer; 303 | void* function(JNIEnv*, jobject) GetDirectBufferAddress; 304 | jlong function(JNIEnv*, jobject) GetDirectBufferCapacity; 305 | jobjectRefType function(JNIEnv*, jobject) GetObjectRefType; 306 | } 307 | 308 | struct _JNIEnv 309 | { 310 | const(JNINativeInterface)* functions; 311 | } 312 | 313 | struct JNIInvokeInterface 314 | { 315 | void* reserved0; 316 | void* reserved1; 317 | void* reserved2; 318 | jint function(JavaVM*) DestroyJavaVM; 319 | jint function(JavaVM*, JNIEnv**, void*) AttachCurrentThread; 320 | jint function(JavaVM*) DetachCurrentThread; 321 | jint function(JavaVM*, void**, jint) GetEnv; 322 | jint function(JavaVM*, JNIEnv**, void*) AttachCurrentThreadAsDaemon; 323 | } 324 | 325 | struct _JavaVM 326 | { 327 | const(JNIInvokeInterface)* functions; 328 | } 329 | 330 | struct JavaVMAttachArgs 331 | { 332 | jint version_; 333 | const(char)* name; 334 | jobject group; 335 | } 336 | 337 | struct JavaVMOption 338 | { 339 | const(char)* optionString; 340 | void* extraInfo; 341 | } 342 | 343 | struct JavaVMInitArgs 344 | { 345 | jint version_; 346 | jint nOptions; 347 | JavaVMOption* options; 348 | jboolean ignoreUnrecognized; 349 | } 350 | 351 | struct _jfieldID; 352 | struct _jmethodID; 353 | 354 | union jvalue 355 | { 356 | jboolean z; 357 | jbyte b; 358 | jchar c; 359 | jshort s; 360 | jint i; 361 | jlong j; 362 | jfloat f; 363 | jdouble d; 364 | jobject l; 365 | } 366 | 367 | jint JNI_OnLoad(JavaVM* vm, void* reserved); 368 | void JNI_OnUnload(JavaVM* vm, void* reserved); 369 | -------------------------------------------------------------------------------- /log.d: -------------------------------------------------------------------------------- 1 | /* dstep -I/path/to/ndk-r9d/toolchains/llvm-3.4/prebuilt/linux-x86/lib/clang/3.4/include /path/to/ndk-r9d/platforms/android-9/arch-x86/usr/include/android/log.h -o log.d*/ 2 | 3 | module android.log; 4 | 5 | import core.stdc.stdarg; 6 | 7 | version (Android): 8 | extern (C): 9 | @system: 10 | nothrow: 11 | @nogc: 12 | 13 | enum android_LogPriority 14 | { 15 | ANDROID_LOG_UNKNOWN, 16 | ANDROID_LOG_DEFAULT, 17 | ANDROID_LOG_VERBOSE, 18 | ANDROID_LOG_DEBUG, 19 | ANDROID_LOG_INFO, 20 | ANDROID_LOG_WARN, 21 | ANDROID_LOG_ERROR, 22 | ANDROID_LOG_FATAL, 23 | ANDROID_LOG_SILENT 24 | } 25 | 26 | int __android_log_write(int prio, const(char)* tag, const(char)* text); 27 | int __android_log_print(int prio, const(char)* tag, const(char)* fmt, ...); 28 | int __android_log_vprint(int prio, const(char)* tag, const(char)* fmt, va_list ap); 29 | void __android_log_assert(const(char)* cond, const(char)* tag, const(char)* fmt, ...); 30 | -------------------------------------------------------------------------------- /sample.d: -------------------------------------------------------------------------------- 1 | import jni; 2 | import std.conv : to; 3 | import std.string; 4 | import core.runtime : rt_init; 5 | extern(C) jstring Java_my_long_package_name_ClassName_methodname(JNIEnv* env, jclass clazz, jstring stringArgReceivedFromJava) 6 | { 7 | rt_init(); 8 | const char* javaStringInCStyle = (*env).GetStringUTFChars(env, stringArgReceivedFromJava, null); 9 | string javaStringInDStyle = to!string(javaStringInCStyle); 10 | (*env).ReleaseStringUTFChars(env, stringArgReceivedFromJava, javaStringInCStyle); 11 | 12 | return (*env).NewUTFString(toStringz("Hello from D, myarg: "~javaStringInDStyle)); 13 | } 14 | void main(){} --------------------------------------------------------------------------------