[Lazarus] Hints for Android

Sven Barth pascaldragon at googlemail.com
Thu Apr 11 21:23:49 CEST 2013


On 11.04.2013 18:48, Graeme Geldenhuys wrote:
> On 2013-04-11 16:35, Sven Barth wrote:
>>
>> With FPC 2.7.1 you can use native and JVM based development.
>
> I guess I have lots to learn. :)  I thought all Android apps are Java
> (JVM) based? What is the difference between Native and JVM Android apps?

First and foremost: Android is basically just a Linux with a different 
userspace. So you are able to write applications that can run on Android 
and Google even provides a Native Development Kit which contains 
binutils and C compilers for Android. To access the GUI though you need 
to go through Java functions and your app must be a library (*.so) that 
can be loaded by the Dalvik VM and communicates using JNI (Java Native 
Interface). There is even a (paid) app that provides a Free Pascal IDE 
together with a (native) FPC compiler (I don't know though whether the 
app itself is written natively or as a JVM one).

The important difference between Java code and native one: you need to 
adjust the native code for each platform while the Java one runs on all 
platforms. E.g. there exists x86-android, arm-android and since some 
time also mips-android (though only the former two are currently 
supported by FPC). Also for ARM you can have different flavors. E.g. 
there are ARMv5 and ARMv6 CPUs and also those with an additional NEON 
FPU (FPC doesn't support that currently, but it would be a nice addition 
:) ).

> Does Android have a X11 server?

As Reimar wrote there exists one which you can use for simple programs, 
but normally you go through the Android GUI. For native programs this 
can be simplified by either using OpenGL or use SDL (which provide a 
port). You could also use QT5 which has an (AFAIK experimental) port for 
Android (though there aren't - again AFAIK - no Pascal bindings yet).

>> and if you want an example
>> JVM application I can send you a link to the source (maybe I'll add a
>> github repo for it...)
>
> I always learn well with an example. So if you can email me a link, that
> would be much appreciated.

I had published the example first here: 
http://lists.lazarus.freepascal.org/pipermail/lazarus/2011-December/069470.html

You'll find a link further down in the thread. Michael also wrote an 
article in the freeX about that based on my app (though he developed his 
own one).

>> After Canonical has announced yet another display server just when Wayland
>> was starting to off they are more of less dead for me...
>
> Oh, changed there minds again. I have dropped Ubuntu since they moved to
> Unity, so don't follow them closely these days.

I've switched from (K)Ubuntu in winter 2008... I've just heard this 
about the Mir display server through Phoronix.

>>From your reply to Michael, I assume LCL's Customdrawn-Android backend
> will generate a "native" Android app? Still not really sure the
> difference between Native and JVM apps. As I said, I thought all apps on
> Android was Java-based, thus runs in a JVM.

Yes, the Customdrawn-Android widgetset is a native one. You don't have 
LCL support for jvm-android, but the IDE works (if you look a bit 
further in the mailing list threads from December 2011 you'll notice me 
complaining about a few things that didn't work back then :) )

Regards,
Sven




More information about the Lazarus mailing list