Update on Android
Posted 2019-10-14
Blog
Articles- terminal.d gets clipboard functions, ldc 1.20 out.
- DConf keynote speaker announced: Lua architect Roberto Ierusalimschy, Named args DIP discussed
- February 3, 2020
- Adam's terminal suite explained
- Understanding mixin templates, terminal.d improvements
- My attribute-by-default proposal. Also dmd 2.090 came out.
- DConf 2020 announced: June 17-20 in London. @safe by default debated. Adam did: Android, JNI, WebSocket in arsd libs
- tar.xz, --DRT tip, dom bug fixes, more Android and JNI, link to old phobos docs
- LDC 1.19 - Android, AVR. My rant on tests, update on JNI and COM.
- Walter's string interpolation proposal is OK but not great. My Android thing nearing beta release. dub downtime explained.
- Android project update, introduction to arsd.jni
- New pattern about interface contracts
- Adam shares Windows console secrets - DO NOT USE chcp!!
- Adam's rant on benchmarks
- Socket tutorial
- November 4, 2019
- October 28, 2019
- arsd package updates, forum nonsense
- Update on Android
- Adam does iOS "goodbye world"
- September 30, 2019
- D turns 20, Adam rants on software freedom
- Named arg DIPs and my thoughts on code organization
- September 9, 2019
- I wrote about mixin templates vs string mixins on Stack Overflow
- August 26, 2019
- Bug bounty in D again - my hot take, on reusing code, a fun picture, my tentative plan for the next month
- Time invested is worth a lot
- cgi.d's new scheduler, static this tricks
- July 29, 2019
- July 22, 2019
- Solving vs managing problems
- A big week in the arsd repo
- July 1, 2019
- June 24, 2019
- June 17, 2019
- CRTP thoughts, named arguments DIP review, DConf videos now on youtube
- musings on hybrid CT/RT tests, some more progress on new web framework
- a little more webassembly
- May 20, 2019
- Adam's string interpolation proposal
- DMD 2.086 live, GCC 9 with D support formally released, DConf coming soon, links to posts on builder pattern and disallowing implicit conversions with templates, and 2d array op overloads
- template constraint error improvements coming?
- dmd 2.086 beta, dstep 1.0 released, Adam works on memory usage
- obj-c and webassembly report, tips on is expressions linked.
- new ldc, new dmd, dpp on the blog
- D's future discussed in forums
- LDC beta, DConf blog link, Adam introduces gamehelpers.d
- March 18, 2019
- LDC 1.15.0-beta1, responsive design rant
- dmd 2.085.0 released
- Obj-C interop and D without druntime code to copy/paste
- dmd beta, more info coming next time, demo of new web framework initial prototype
- automatic web interface discussion, reflection tips and tricks
- Adam busy with weather and a move, lots of community announcements
- January 28, 2019
- Working on official blog 2018 retro, C++ new wrapped, dmd reading zips?
- dmd obj-c growing, Adam static foreaches an interface to RPC
- dmd 2.084, hope for future, but busy non-D week for me
- IDE tools released, my cgi.d gets new features
- DConf announced, tip, Adam rants: mouse trap
- This Week in D is back!
D on android almost just works out of the box - ldc can build D code, as well as the D runtime, for the android platform and package it into a shared lib. The part I'm fighting with is just integrating it ergonomically.
Core D Development Statistics
In the community
Community announcements
See more at the announce forum.
What Adam is working on
ldc functions as a cross-compiler out of the box. You can simply download the pre-build version for your host platform and pass arguments to it to get it to generate programs for other platforms. The only tricky part is getting the D runtime to work there, and that's actually pretty easy too - you can download a pre-built one for that platform and copy it in, or build it with a helper program that comes with ldc called ldc-build-runtime.
Getting specific with android, starting with the instructions on the d wiki, and using ldc-build-runtime, I ran:
And got it to build for me. I had to specify CMAKE_C_COMPILER since my system uses gcc by default (I sent a patch to ldc to fix this) and the LDC_EXE_FULL I think is required because I was using a git version.
ldc-build-runtime will try to download the ldc version. Since I was using the git one, I had to put the source inside the build directory - droid64 here - and call the subdirectory ldc-src.
But then it worked. I compiled and linked separately - compile with the appropriate mtriple (see below), then link using the linker provided with the Android ndk. I did NOT do any special steps for building a cross compiler and did NOT use clang to link, like the wiki says. I believe it is easier now than it was when that was written.
On my system, the link command ended up being:
Note the long starting command is just calling the ld.bfd command from the ndk directory I downloaded from google's website.
My trouble
The problem is I still don't know how to make the apk. I haven't worked with Android before and don't know gradle or the IDE. I'm sure I'll get there eventually though and when I do, I'll let you all know.
Appendix - list of common -mtriple values
The format of these is arch-vendor-os-variant.
Windows PCs
Macintoshes
ARM Linux, e.g. raspberry pi
iphones and ipads
android devices
Web assembly