June 02, 2017
On Friday, 2 June 2017 at 09:39:46 UTC, Petar Kirov [ZombineDev] wrote:
> On Friday, 2 June 2017 at 08:58:01 UTC, Joakim wrote:
>> On Friday, 2 June 2017 at 08:36:49 UTC, Dušan Pavkov wrote:
>>> On Thursday, 1 June 2017 at 19:31:28 UTC, Joakim wrote:
>>>> The beta release of ldc 1.3, the llvm-based D compiler, is now out:
>>>>
>>>> https://github.com/joakim-noah/android/releases
>>>>
>>>> It is accompanied by a non-trivial sample app from the Android NDK, ported from C++ to about 1.2 klocs of D: the classic Utah Teapot (https://en.wikipedia.org/wiki/Utah_teapot), updated with mobile touch controls.  This app also demonstrates calling Java functions from your D code through JNI, though most of it is written in D.
>>>>
>>>> There are two builds of ldc, a cross-compiler that you can use from a linux/x64 shell to compile to Android/ARM, and a native compiler that you can run on your Android device itself.  As I pointed out last year, not only is ldc a large mixed D/C++ codebase that just worked on ARM, but it is possible to build arbitrarily large Android apps on your Android device itself, a first for any mobile platform:
>>>>
>>>> http://forum.dlang.org/thread/ovkhtsdzlfzqrqneolyv@forum.dlang.org
>>>>
>>>> This is the way the next generation of coders will get into coding, by tinkering with their Android devices like we did with Macs and PCs decades ago, and D is one the few languages that is already there.
>>>>
>>>> I will write up instructions on how to write an Android app in D _on_ your Android device by using ldc and the Termux app, and get ldc into the Termux packages, a package repository for Android:
>>>>
>>>> https://play.google.com/store/apps/details?id=com.termux&hl=en
>>>
>>> Hello,
>>>
>>> Thanks for the post. I have tried to run apk on 2 devices:
>>> 1. LG-E440 phone with Android 4.1.2
>>> 2. Orange Pi Lite (development board with Allwinner H3 CPU) Android 4.4.2
>>>
>>> On both devices there was only gray rectangle with "Teapot" notification at the bottom for about a sec and then in upper left corner the FPS info (around 60 on both devices), but without any graphic. I have tried taping, dragging etc.
>>>
>>> Are Android versions a problem or it could be something else?
>>>
>>> Thanks in advance.
>>
>> I'd guess that's the issue, as I haven't tested against those older versions of Android and this app links against Android API 21, ie 5.0 Lollipop:
>>
>> https://github.com/joakim-noah/android/blob/master/samples/Teapot/build-apk#L17
>>
>> I'm pretty sure it'd work for your older Android versions if built slightly differently, as I used to support back to Android API 9 until a couple months ago:
>>
>> https://gist.github.com/joakim-noah/f475b0be37b3834b4e50d68996b6ee1d#file-ldc_1-1-0_android_arm-L3438
>>
>> It can be still made to so but I set API 21 as the minimum, because anything older has been declining for some time now:
>>
>> http://blog.davidecoppola.com/2016/12/android-version-distribution-history-visualization-2012-2016/
>
> Just FYI, I have the same issue with Android 6.0.1.

Hmm, is that the 64-bit Xiaomi device you mentioned in the github issues just now?  My guess there would be that it's because ldc only supports 32-bit Android/ARM devices right now, and 64-bit devices like Xiaomi probably don't run 32-bit native Android libraries in their apps, though I don't know that for sure.  I just tried installing the teapot app on another 32-bit 6.0.1 phone that I'd never tried before, worked fine.

This is not an issue for Java, because the Android runtime compiles Java bytecode to native code _after_ the app is downloaded, but other languages have to provide pre-compiled libraries for each CPU architecture.  Not a big deal as there are only really two in wide deployment, 32-bit and 64-bit ARM, with the vast majority 32-bit right now.

Perhaps you can help us get on 64-bit ARM, as you mentioned in the github issues.
June 02, 2017
On Friday, 2 June 2017 at 10:12:27 UTC, Joakim wrote:
> On Friday, 2 June 2017 at 09:39:46 UTC, Petar Kirov [ZombineDev] wrote:
>> On Friday, 2 June 2017 at 08:58:01 UTC, Joakim wrote:
>>> On Friday, 2 June 2017 at 08:36:49 UTC, Dušan Pavkov wrote:
>>>> On Thursday, 1 June 2017 at 19:31:28 UTC, Joakim wrote:
>>>>> The beta release of ldc 1.3, the llvm-based D compiler, is now out:
>>>>>
>>>>> https://github.com/joakim-noah/android/releases
>>>>>
>>>>> It is accompanied by a non-trivial sample app from the Android NDK, ported from C++ to about 1.2 klocs of D: the classic Utah Teapot (https://en.wikipedia.org/wiki/Utah_teapot), updated with mobile touch controls.  This app also demonstrates calling Java functions from your D code through JNI, though most of it is written in D.
>>>>>
>>>>> There are two builds of ldc, a cross-compiler that you can use from a linux/x64 shell to compile to Android/ARM, and a native compiler that you can run on your Android device itself.  As I pointed out last year, not only is ldc a large mixed D/C++ codebase that just worked on ARM, but it is possible to build arbitrarily large Android apps on your Android device itself, a first for any mobile platform:
>>>>>
>>>>> http://forum.dlang.org/thread/ovkhtsdzlfzqrqneolyv@forum.dlang.org
>>>>>
>>>>> This is the way the next generation of coders will get into coding, by tinkering with their Android devices like we did with Macs and PCs decades ago, and D is one the few languages that is already there.
>>>>>
>>>>> I will write up instructions on how to write an Android app in D _on_ your Android device by using ldc and the Termux app, and get ldc into the Termux packages, a package repository for Android:
>>>>>
>>>>> https://play.google.com/store/apps/details?id=com.termux&hl=en
>>>>
>>>> Hello,
>>>>
>>>> Thanks for the post. I have tried to run apk on 2 devices:
>>>> 1. LG-E440 phone with Android 4.1.2
>>>> 2. Orange Pi Lite (development board with Allwinner H3 CPU) Android 4.4.2
>>>>
>>>> On both devices there was only gray rectangle with "Teapot" notification at the bottom for about a sec and then in upper left corner the FPS info (around 60 on both devices), but without any graphic. I have tried taping, dragging etc.
>>>>
>>>> Are Android versions a problem or it could be something else?
>>>>
>>>> Thanks in advance.
>>>
>>> I'd guess that's the issue, as I haven't tested against those older versions of Android and this app links against Android API 21, ie 5.0 Lollipop:
>>>
>>> https://github.com/joakim-noah/android/blob/master/samples/Teapot/build-apk#L17
>>>
>>> I'm pretty sure it'd work for your older Android versions if built slightly differently, as I used to support back to Android API 9 until a couple months ago:
>>>
>>> https://gist.github.com/joakim-noah/f475b0be37b3834b4e50d68996b6ee1d#file-ldc_1-1-0_android_arm-L3438
>>>
>>> It can be still made to so but I set API 21 as the minimum, because anything older has been declining for some time now:
>>>
>>> http://blog.davidecoppola.com/2016/12/android-version-distribution-history-visualization-2012-2016/
>>
>> Just FYI, I have the same issue with Android 6.0.1.
>
> Hmm, is that the 64-bit Xiaomi device you mentioned in the github issues just now?

Yep

> My guess there would be that it's because ldc only supports 32-bit Android/ARM devices right now, and 64-bit devices like Xiaomi probably don't run 32-bit native Android libraries in their apps, though I don't know that for sure.  I just tried installing the teapot app on another 32-bit 6.0.1 phone that I'd never tried before, worked fine.

Running 32-bit apps on 64-bit Android, shouldn't be an issue as far I know. See:
https://stackoverflow.com/questions/30782848/how-to-use-32-bit-native-libraries-on-64-bit-android-device

> This is not an issue for Java, because the Android runtime compiles Java bytecode to native code _after_ the app is downloaded, but other languages have to provide pre-compiled libraries for each CPU architecture.  Not a big deal as there are only really two in wide deployment, 32-bit and 64-bit ARM, with the vast majority 32-bit right now.
>
> Perhaps you can help us get on 64-bit ARM, as you mentioned in the github issues.

Yes, ultimately I'm interested in writing a Vulkan library that runs on both 32 and 64-bit Linux, Windows and Android, so I'm interested in helping with the AArch64 support too, though my compiler-foo is pretty slim. As mentioned in the GH issue [0], what do I need to bootstrap LDC on Android?

[0]: https://github.com/joakim-noah/android/issues/10

June 02, 2017
On Friday, 2 June 2017 at 10:40:48 UTC, Petar Kirov [ZombineDev] wrote:
> On Friday, 2 June 2017 at 10:12:27 UTC, Joakim wrote:
>> On Friday, 2 June 2017 at 09:39:46 UTC, Petar Kirov [ZombineDev] wrote:
>>> On Friday, 2 June 2017 at 08:58:01 UTC, Joakim wrote:
>>>> On Friday, 2 June 2017 at 08:36:49 UTC, Dušan Pavkov wrote:
>>>>> [...]
>>>>
>>>> I'd guess that's the issue, as I haven't tested against those older versions of Android and this app links against Android API 21, ie 5.0 Lollipop:
>>>>
>>>> https://github.com/joakim-noah/android/blob/master/samples/Teapot/build-apk#L17
>>>>
>>>> I'm pretty sure it'd work for your older Android versions if built slightly differently, as I used to support back to Android API 9 until a couple months ago:
>>>>
>>>> https://gist.github.com/joakim-noah/f475b0be37b3834b4e50d68996b6ee1d#file-ldc_1-1-0_android_arm-L3438
>>>>
>>>> It can be still made to so but I set API 21 as the minimum, because anything older has been declining for some time now:
>>>>
>>>> http://blog.davidecoppola.com/2016/12/android-version-distribution-history-visualization-2012-2016/
>>>
>>> Just FYI, I have the same issue with Android 6.0.1.
>>
>> Hmm, is that the 64-bit Xiaomi device you mentioned in the github issues just now?
>
> Yep
>
>> My guess there would be that it's because ldc only supports 32-bit Android/ARM devices right now, and 64-bit devices like Xiaomi probably don't run 32-bit native Android libraries in their apps, though I don't know that for sure.  I just tried installing the teapot app on another 32-bit 6.0.1 phone that I'd never tried before, worked fine.
>
> Running 32-bit apps on 64-bit Android, shouldn't be an issue as far I know. See:
> https://stackoverflow.com/questions/30782848/how-to-use-32-bit-native-libraries-on-64-bit-android-device

64-bit ARMv8 hardware should run 32-bit ARMv7 binaries, but it depends on software support too, like providing the 32-bit system shared libraries that this 32-bit teapot shared library links against.  I found that SO link inconclusive, but I just found this blog post from a couple years ago that says that it depends on the device:

https://ph0b.com/android-abis-and-so-files/

With your 64-bit device, either it doesn't list ARMv7 as a supported ABI or there's some bug that's stopping it from running this 32-bit ARMv7 library on ARMv8.

>> This is not an issue for Java, because the Android runtime compiles Java bytecode to native code _after_ the app is downloaded, but other languages have to provide pre-compiled libraries for each CPU architecture.  Not a big deal as there are only really two in wide deployment, 32-bit and 64-bit ARM, with the vast majority 32-bit right now.
>>
>> Perhaps you can help us get on 64-bit ARM, as you mentioned in the github issues.
>
> Yes, ultimately I'm interested in writing a Vulkan library that runs on both 32 and 64-bit Linux, Windows and Android, so I'm interested in helping with the AArch64 support too, though my compiler-foo is pretty slim. As mentioned in the GH issue [0], what do I need to bootstrap LDC on Android?
>
> [0]: https://github.com/joakim-noah/android/issues/10

I've followed up on github, we can discuss there.
June 02, 2017
On Thursday, 1 June 2017 at 19:45:17 UTC, Ali Çehreli wrote:
> Very exciting! :)
>
> On 06/01/2017 12:31 PM, Joakim wrote:
>
> > I will write up instructions on how to write an Android app
> in D _on_
> > your Android device
>
> I hope it will be detailed enough for people who are very new to programming on the Android.

Yes, the goal is to document all the steps, like I do on the wiki for cross-compiling now, but more so because it's completely new to most and requires a few more steps than the official NDK/SDK.  But the official NDK requires using or mimicking their build system and the SDK can be a bear to setup, as they give you a ton of stuff like an IDE and emulators, so this might actually be easier overall.

On Thursday, 1 June 2017 at 21:54:59 UTC, Johan Engelen wrote:
> On Thursday, 1 June 2017 at 19:31:28 UTC, Joakim wrote:
>> [awesome text]
>
> This is great stuff Joakim!
> It's very nice to see your detailed release notes, with links to the patches. Hope we can get much of that into LDC master soon.

There's not much left, the cross-compiler doesn't require any patches and the remaining tweaks to druntime/phobos are minimal.  I'll get the last bits in, with the exception of that workaround in std.stdio for the regression specific to Android 5.0.

On Friday, 2 June 2017 at 00:00:17 UTC, Laeeth Isharc wrote:
> Congratulations, Joakim!
> https://www.reddit.com/r/programming/comments/6eqv46/write_mixed_dc_android_apps_even_build_them/
> and news.ycombinator.com
>
> Looking forward to termux.

Thanks for publicizing it, looks like you've started a discussion on reddit.
June 02, 2017
On Thursday, June 01, 2017 19:31:28 Joakim via Digitalmars-d-announce wrote:
> The beta release of ldc 1.3, the llvm-based D compiler, is now out:
>
> https://github.com/joakim-noah/android/releases
>
> It is accompanied by a non-trivial sample app from the Android NDK, ported from C++ to about 1.2 klocs of D: the classic Utah Teapot (https://en.wikipedia.org/wiki/Utah_teapot), updated with mobile touch controls.  This app also demonstrates calling Java functions from your D code through JNI, though most of it is written in D.
>
> There are two builds of ldc, a cross-compiler that you can use from a linux/x64 shell to compile to Android/ARM, and a native compiler that you can run on your Android device itself.  As I pointed out last year, not only is ldc a large mixed D/C++ codebase that just worked on ARM, but it is possible to build arbitrarily large Android apps on your Android device itself, a first for any mobile platform:
>
> http://forum.dlang.org/thread/ovkhtsdzlfzqrqneolyv@forum.dlang.org
>
> This is the way the next generation of coders will get into coding, by tinkering with their Android devices like we did with Macs and PCs decades ago, and D is one the few languages that is already there.
>
> I will write up instructions on how to write an Android app in D _on_ your Android device by using ldc and the Termux app, and get ldc into the Termux packages, a package repository for Android:
>
> https://play.google.com/store/apps/details?id=com.termux&hl=en

Yay! I keep meaning to check out programming for Android, but as with far too many things, I never get around to it. But if I program for something like Android, I'd definitely prefer to be doing it in D. A huge thanks to you and everyone else who's worked on this!

- Jonathan M Davis

June 04, 2017
On Friday, 2 June 2017 at 00:00:17 UTC, Laeeth Isharc wrote:
> On Thursday, 1 June 2017 at 19:31:28 UTC, Joakim wrote:
>> [...]
>
> Congratulations, Joakim!
> https://www.reddit.com/r/programming/comments/6eqv46/write_mixed_dc_android_apps_even_build_them/
> and news.ycombinator.com
>
> Looking forward to termux.

Haha, I lol'ed when I just read this comment:

"Ah, D only came into my field of view with the recent support on Android and I assumed it was a recent language designed for Android."
https://www.reddit.com/r/programming/comments/6eqv46/comment/dif3sa0

Well, at least we're getting more of these Android people introduced to D.
June 11, 2017
On Thursday, 1 June 2017 at 19:31:28 UTC, Joakim wrote:
> The beta release of ldc 1.3, the llvm-based D compiler, is now out:
>
> https://github.com/joakim-noah/android/releases
>
---snip---
> I will write up instructions on how to write an Android app in D _on_ your Android device by using ldc and the Termux app, and get ldc into the Termux packages, a package repository for Android:
>
> https://play.google.com/store/apps/details?id=com.termux&hl=en

I've now put up a deb file at the first release link above that you can install in the Termux app, the result of this PR to get ldc into the Termux package repository for Android:

https://github.com/termux/termux-packages/pull/1078

Try the deb file out by installing the Termux app, then running the following commands:

apt install clang curl
curl -L -O https://github.com/joakim-noah/android/releases/download/tea/ldc_1.3.0_arm.deb
dpkg -i ldc
ldc2 --version

Once ldc gets into the Termux package repository, all you'll need to run is "apt install ldc".  Finally, try to build your favorite D file:

ldc2 sieve.d
June 11, 2017
On Sunday, 11 June 2017 at 04:15:13 UTC, Joakim wrote:
> On Thursday, 1 June 2017 at 19:31:28 UTC, Joakim wrote:
>>[...]
> ---snip---
>> [...]
>
> I've now put up a deb file at the first release link above that you can install in the Termux app, the result of this PR to get ldc into the Termux package repository for Android:
>
> https://github.com/termux/termux-packages/pull/1078
>
> Try the deb file out by installing the Termux app, then running the following commands:
>
> apt install clang curl
> curl -L -O https://github.com/joakim-noah/android/releases/download/tea/ldc_1.3.0_arm.deb
> dpkg -i ldc
> ldc2 --version
>
> Once ldc gets into the Termux package repository, all you'll need to run is "apt install ldc".  Finally, try to build your favorite D file:
>
> ldc2 sieve.d

Sorry, that should be:

dpkg -i ldc_1.3.0_arm.deb
June 19, 2017
So, how its app can work with mobile recorder https://mobilerecorder24.com/ on Android?
August 26, 2017
On Thursday, 1 June 2017 at 19:45:17 UTC, Ali Çehreli wrote:
> Very exciting! :)
>
> On 06/01/2017 12:31 PM, Joakim wrote:
>
> > I will write up instructions on how to write an Android app
> in D _on_
> > your Android device
>
> I hope it will be detailed enough for people who are very new to programming on the Android.
>
> Ali

I've finally written up full instructions on building D apps for Android by using the linux cross-compiler or native Android compiler I provide:

https://wiki.dlang.org/Build_D_for_Android

The upcoming ldc 1.4 beta will be the first to include Android cross-compilation support for all supported host platforms, ie Windows, Mac, and linux, as all my Android patches have now been merged.  I'll stop putting out my own cross-compiler builds, though I'll maintain the native ldc package in the Termux package repo, once that's accepted.

If you want to build full OpenGLES GUI Android apps on your Android device, this wiki page shows you how to do that too.  You too can be one of the elite few building mobile apps on your mobile device, and in D!