Difference between revisions of "Build Android Apps using LDC in a Container"
m (clang command corrected) |
m (Building Android APK chapter added) |
||
Line 10: | Line 10: | ||
- Android SDK [https://developer.android.com/studio/index.html] | - Android SDK [https://developer.android.com/studio/index.html] | ||
+ | Create an environment variable SDK which points to the installation/extraction directory of | ||
+ | the Android SDK. | ||
- Ant [https://ant.apache.org/] | - Ant [https://ant.apache.org/] | ||
+ | Add the ...\ant\bin\ path to your PATH environment variable | ||
Line 44: | Line 47: | ||
mkdir -p libs/armeabi-v7a/ | mkdir -p libs/armeabi-v7a/ | ||
− | $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -Wl,-soname,libnative-activity.so -shared --sysroot=$NDK/platforms/android-9/arch-arm main.o sensor.o $LDC/lib/libphobos2-ldc.a $LDC/lib/libdruntime-ldc.a android_native_app_glue.o -lgcc -gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -no-canonical-prefixes -fuse-ld=bfd -target armv7-none-linux-androideabi -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -mthumb -L$NDK/platforms/android-9/arch-arm/usr/lib -llog -landroid -lEGL -lGLESv1_CM -lc -lm -o libs/armeabi-v7a/libnative-activity.so | + | $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -Wl,-soname,libnative-activity.so -shared --sysroot=$NDK/platforms/android-9/arch-arm main.o sensor.o $LDC/lib/libphobos2-ldc.a $LDC/lib/libdruntime-ldc.a android_native_app_glue.o -lgcc -gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -no-canonical-prefixes -fuse-ld=bfd -target armv7-none-linux-androideabi -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -mthumb -L$NDK/platforms/android-9/arch-arm/usr/lib -llog -landroid -lEGL -lGLESv1_CM -lc -lm -o libs/armeabi-v7a/libnative-activity.so |
+ | exit'' | ||
== 4. Build Android APK (Within host operation system)== | == 4. Build Android APK (Within host operation system)== | ||
+ | |||
+ | ''cd C:\D\projects\android\samples\native-activity | ||
+ | |||
+ | %SDK%\tools\android update project -p . -s --target 1 | ||
+ | |||
+ | ant debug'' |
Revision as of 17:16, 19 January 2017
Work in progress
Using Docker it is easy to create Android Applications. Although this page shows you how to create Android Apps on a Windows system, it also works for Linux and Mac operation systems. You have to adapt the directory paths according to your operation system.
You need to have following software installed on your host operation system:
- Docker (Docker for Windows)
- Java Development Kit (JDK)
- Android SDK [1] Create an environment variable SDK which points to the installation/extraction directory of the Android SDK.
- Ant [2] Add the ...\ant\bin\ path to your PATH environment variable
Contents
1. Clone Android Headers / Demos
Clone the repository https://github.com/joakim-noah/android into folder c:\D\projects.
git clone https://github.com/joakim-noah/android
2. Start docker
This command will pull the image andre2007/ldc-android from the docker hub and starts a shell within the container. Also the path c:\D\projects will be mounted as \projects.
docker run --rm -it -v c:/D/projects:/projects andre2007/ldc-android sh
3. Compile the demo (Within container)
Within the container shell execute following commands:
cd /projects/android/samples/native-activity/
ldc2 -I../../ -c jni/main.d
ldc2 -I../../ -c ../../android/sensor.d
ldc2 -I../../ -c ../../android_native_app_glue.d
mkdir -p libs/armeabi-v7a/
$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -Wl,-soname,libnative-activity.so -shared --sysroot=$NDK/platforms/android-9/arch-arm main.o sensor.o $LDC/lib/libphobos2-ldc.a $LDC/lib/libdruntime-ldc.a android_native_app_glue.o -lgcc -gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64 -no-canonical-prefixes -fuse-ld=bfd -target armv7-none-linux-androideabi -Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -mthumb -L$NDK/platforms/android-9/arch-arm/usr/lib -llog -landroid -lEGL -lGLESv1_CM -lc -lm -o libs/armeabi-v7a/libnative-activity.so
exit
4. Build Android APK (Within host operation system)
cd C:\D\projects\android\samples\native-activity
%SDK%\tools\android update project -p . -s --target 1
ant debug