Lazarus

Programming => Operating Systems => Android => Topic started by: djdjdjole on October 01, 2012, 06:52:30 pm

Title: Lazarus on Android
Post by: djdjdjole on October 01, 2012, 06:52:30 pm
I have some moderate experience in using Lazarus in Windows and Linux. Now I am interested in programing Android applications using Lazarus. Can anyone explain me or point me to articles/sites where I can learn more about the matter.
Can I use Lazarus installed on Linux or Windows machine for compiling Android applications ? What should I do to enable compiling for Android using Lazarus IDE ? Do I need to build Android like I usually did with Linux ?

Regards
Title: Re: Lazarus on Android
Post by: eMarc on October 01, 2012, 08:20:47 pm
Hello.

Take a look here :

http://wiki.lazarus.freepascal.org/Custom_Drawn_Interface/Android

It's easier than it seems, ask for any doubt.
Title: Re: Lazarus on Android
Post by: tatamata on October 01, 2012, 10:42:41 pm
Maybe sounds crazy, but, last half of year I'm almost exclusively on an Android tablet (Transformer Prime with docking keyboard), so I'm wondering whether and when am I going to be able to use Lazarus on android?
I mean, not to compile for Android, but to program on android?
Title: Re: Lazarus on Android
Post by: Leledumbo on October 02, 2012, 08:19:27 am
Quote
I mean, not to compile for Android, but to program on android?
:o
It's theoritically possible though, using the same approach as current (so the IDE resides in a .so), but who wants to complete it? :-[
Title: Re: Lazarus on Android
Post by: djdjdjole on October 14, 2012, 02:18:35 pm
I have red tutorial http://wiki.lazarus.freepascal.org/Custom_Drawn_Interface/Android
and I am in doubt if it states two possible paths - one using VirutalBox and the other by building/installing precompiled FPC. Or should I do both steps, which I doubt, because VritualBox already contains FPC ?
Because I successfully installed everything needed to compile linux ARM applications, (and made few), I prefer Linux solution. However, in tutorial, I don't see steps for installing Android SDK and NDK in Linux (and maybe something else -what if so ?) like it was for Windows.
I don't know why, or I missunderstand something.

Regards
Title: Re: Lazarus on Android
Post by: felipemdc on October 16, 2012, 08:51:05 am
I have red tutorial http://wiki.lazarus.freepascal.org/Custom_Drawn_Interface/Android
and I am in doubt if it states two possible paths - one using VirutalBox and the other by building/installing precompiled FPC. Or should I do both steps, which I doubt, because VritualBox already contains FPC ?

The VirtualBox is very old, so I would go with the more manual path if I were you.

Quote
Because I successfully installed everything needed to compile linux ARM applications, (and made few), I prefer Linux solution. However, in tutorial, I don't see steps for installing Android SDK and NDK in Linux (and maybe something else -what if so ?) like it was for Windows.

It is necessary to install the SDK and NDK in Linux too. In the VirtualBox image they are already installed.
Title: Re: Lazarus on Android
Post by: djdjdjole on October 16, 2012, 09:22:38 am
Thank's felipemdc. Although, you didn't mention, but I suppose, I have to install Java SDK, too. If you have some proposals regarding versions (SDKs, NDK), it would be nice.

Regards
Title: Re: Lazarus on Android
Post by: felipemdc on October 16, 2012, 09:37:08 am
Thank's felipemdc. Although, you didn't mention, but I suppose, I have to install Java SDK, too.

Yes, it is also necessary.

Quote
If you have some proposals regarding versions (SDKs, NDK), it would be nice.

I think that the latest ones should work.
Title: Re: Lazarus on Android
Post by: djdjdjole on October 16, 2012, 11:35:02 am
Although, I consider tutorials as very usefull articles, I suppose it would be awesome if someone would make an explanation of process of building Android application with Lazarus. For example, how some function's call or widgets drawing or ... relates to what part of Android SDK or NDK and where is JDK in path of compiling and executing application.
I intend to try the steps in tutorial, whether Windows of Linux based, but consider that it would be good to know what and why in fact I am doing.
Also, is  Lazarus 1.0 OK, because I somehow found the combination of FPC and Lazarus that successfully bild my ARM board's applications (with 1.1, I didn't have success - http://forum.lazarus.freepascal.org/index.php/topic,17950.0.html).

Regards
Title: Re: Lazarus on Android
Post by: djdjdjole on October 17, 2012, 03:20:22 pm
Here is the problem I faced, after generating key and try building script (this is excerpt from output):

.
.
.
Note: src\com\pascal\lcltest\LCLActivity.java uses uncecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

trouble processing:
bad class file magic <cafebabe> of version <0033.0000>
...while parsing com/pascal/lcltest/LCLActivity$1.class
...while processing com/pascal/lcltest/LCLActivity$1.class

<THERE FOLLOW MORE WARNINGS OF SIMILAR CONTENT>
.
.
.
14 warnings
no classfiles specified

THIS TOOL IS DEPRECATED. See --help for more information.

java.io.FileNotFoundException: C:\lazarus\examples\androidlcl\android\bin\classes.dex does not exist
Could Not find C:\lazarus\examples\androidlcl\android\bin\androidlcltest-unaligned.apk
Unable to open 'bin\androidlcltest-unaligned.apk' as zip archive

Result is that "androidlcl_ap_" file was generated, and "androidlcltest_unsigned.apk has size of 0.
Platfrom that I downloaded is android-16. Wherever was "Program Files", I used "Progra~1" in .bat files.

I hope someone can help.

Regards
Title: Re: Lazarus on Android
Post by: djdjdjole on October 17, 2012, 05:14:25 pm
At the end of my working time I tried with earlier JDK version. Before that I delete debug key file and generate new one. Then started another script and it passes well (..._unsigned.apk generated), until the point where it says:
keystore load: Keystore was tampered with, or password was incorrect.
Didn't have time to inspect the matter, however it is strange, because key was generated a minute before !!! (maybe key should not be deleted simply by removing the file).

Regards
 
Title: Re: Lazarus on Android
Post by: djdjdjole on October 18, 2012, 07:09:41 pm
I didn't noticed in tutorial, but comprehend too late, that one must also change password at the bottom of one of two .bat files (the one for building purposes). That must be according to passwords entered during key generation.
Then I successfully compiled example and got signed .apk file.
However, when transfered to a phone, it states that application terminated unexpectedly. Phone has Android 2.3 and I installed API version 8 (2.2).
File size is 1.3 Mb, and I don't know if it is OK, since I think I saw somewhere that someone states the file size is 5Mb.  Also it is a little bit strange to me the name of lib... file (after compiling in Lazarus) having  ".so.so" at the end.
I hope someone can help me.

Regards
Title: Re: Lazarus on Android
Post by: Fortuna1 on October 19, 2012, 06:24:43 am
".so.so"
just rename  to .so


or 
change in lazarus
Compiler Options
Paths

change this
android/libs/armeabi/liblclapp.so  to android/libs/armeabi/liblclapp

Next step is

cd C:\lazarus\examples\androidlcl\android

generate_debug_key  //change path

build_debug_apk      //change path and put   (user an password generate with  generate_debug_key )


and then get  apk

Title: Re: Lazarus on Android
Post by: djdjdjole on October 19, 2012, 10:18:18 am
Yes, I' ve already note it (so.so stuff) and changed it first thing in the morning. Interesting is that .apk almost doubled at size. Works on phone.
I should try something other than this example.

Does someone know if Lazarus network components and serial communication (5do - synaser) work on android platform ? Serial communication is interesting to me for some ARM board (not the phone) that I have (4 COM ports).
What about bluetooth ?

Regards
Title: Re: Lazarus on Android
Post by: irw10062 on October 20, 2012, 04:44:58 am


The VirtualBox is very old, so I would go with the more manual path if I were you.


Sir,
maybe you could make new virtualbox with latest update support arm android & i386 linux
and maybe with support svn so we only can update if needed
i build my linux program using virtualbox too from windows
Title: Re: Lazarus on Android
Post by: jls890 on November 11, 2012, 10:14:11 pm
I just gave up on Android. Too hard.:( Tried everything, Linux, Windows and that Linux image and nothing worked.
Title: Re: Lazarus on Android
Post by: Leledumbo on November 12, 2012, 12:18:48 am
Quote
I just gave up on Android. Too hard. Tried everything, Linux, Windows and that Linux image and nothing worked.
The current state is not really friendly for new comers, maybe better in the future. I also decided to go with FPC JVM instead of LCL due to size problem, though I lost single source capability as a consequence.
Title: Re: Lazarus on Android
Post by: jls890 on November 12, 2012, 02:41:57 am
Hi Leledumbo.

For Android I just succeeded creating an aplication with Basic4ppc, and for JVM, with Jabaco BETA.

P.S. LCL means Lazarus Component Library? FPC JVM does not work with Lazarus?
Title: Re: Lazarus on Android
Post by: Leledumbo on November 12, 2012, 09:37:51 am
Quote
LCL means Lazarus Component Library?
Yes
Quote
FPC JVM does not work with Lazarus?
If you mean LCL, no. If you mean can you use Lazarus as IDE while you compile using FPC JVM, yes (in fact, this is what I do to make a good use of code browsing feature for the huge android14 unit).