Recent

Author Topic: Android agan...  (Read 11077 times)

Kamau

  • Jr. Member
  • **
  • Posts: 67
  • Old Delphi programmer
Android agan...
« on: May 05, 2015, 12:17:57 pm »
Hi, I'm using version 1.4.0 with FPC 2.6.4. I've been programming since 1974 in machinecode, assembler, basic, pascal going on to Delphi in te nineties. I've been using, dos, windows, unix-es, linux-es and VAX.

But I have never compiled for another operating system than the native one.

I find the description on how to compile for Android hard (very hard or impossible within my experience-base) to understand.

Is there a sample-project which I can download to get started? A sample-project which sets all necessary things in the compiler and linker etc.

If necessary I'll install any Lazarus version on any system, Windows or Linux, to get started.

/Kamau

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Android agan...
« Reply #1 on: May 05, 2015, 03:03:00 pm »
First you need to choose the architecture of the app. Since you didn't say anything about that, there are at least 4 architectures possible:

1> Java + Pascal Library (via JNI).
2> Pascal library with OpenGL graphics
3> Laz4Android
4> LCL-CustomDrawn

For architectures 1 and 2 you can find an example for this here:

https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/bindings/android-ndk/examples/jnitest/

Study the example (supposing thats the architecture you are going for).

Build instructions:

http://wiki.lazarus.freepascal.org/Android_Programming#Build_the_NDK_OpenGL_example

For architecture 3 there is: http://wiki.lazarus.freepascal.org/Android_tutorial

Quote
Is there a sample-project which I can download to get started? A sample-project which sets all necessary things in the compiler and linker etc.

The example project cannot possibly configure everything necessary, since a lot of preparation for building is necessary. I personally do:

1> Install Lazarus with FPC 2.6.4 in Windows
2> Download fpc trunk source code with SVN
3> Build cross-compiler
4> Merge the cross-compiler into FPC 2.6.4
and ready

This wiki link should explain how to do this: http://wiki.freepascal.org/Android#Building_cross_compiler
« Last Edit: May 05, 2015, 03:07:00 pm by felipemdc »

Kamau

  • Jr. Member
  • **
  • Posts: 67
  • Old Delphi programmer
Re: Android agan...
« Reply #2 on: May 05, 2015, 03:16:50 pm »
Thank you for the reply.

I will check your proposals.

/Kamau

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 251
    • Fresh sound.
Re: Android agan...
« Reply #3 on: May 06, 2015, 07:06:39 pm »
hI,

you could try my installer called "laztoapk".

Download from here https://sourceforge.net/projects/laztoapk/files/?source=navbar

You must follow the instruction in the pdf-file, otherwise you will not get it working!

Have fun.

Sam
Linux Mint 19.1, Lazarus 2.0, Windows 7&10, Delphi 7, Delphi 10.3 Rio

Kamau

  • Jr. Member
  • **
  • Posts: 67
  • Old Delphi programmer
Re: Android agan...
« Reply #4 on: May 07, 2015, 06:38:06 am »
Thank you for the suggestion. I have tried it before, but I see that there is an update.

Never the less... Same result this time. "No NDK platform found" and "No SDK Build-Tools found" although both are installed.

It would be helpful to have an idea of which filename(s) are searched, in ordet to knwo which directory to select.

I am on mobile phone internet in the middle of Africa. All downloads above 100MB are costly. 1GB takes at least 16hrs and may be interrupted any time.

/Kamau

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 251
    • Fresh sound.
Re: Android agan...
« Reply #5 on: May 07, 2015, 06:11:13 pm »
Hello,

this is the advantage of an open-source project. You can look/improve the code:
http://sourceforge.net/p/laztoapk/svn/HEAD/tree/trunk/source/apkmanagermain.pas

See methods DetectInstalledNDKPlatforms and DetectInstalledSDKBuildTools.

Regards,
Sam
Linux Mint 19.1, Lazarus 2.0, Windows 7&10, Delphi 7, Delphi 10.3 Rio

Kamau

  • Jr. Member
  • **
  • Posts: 67
  • Old Delphi programmer
Re: Android agan...
« Reply #6 on: May 08, 2015, 09:47:07 am »
Total response i evident and clear.

Don't attempt Android applications from Lazarus!

That's okay because Lazarus is a magnificent program, with heartfelt thanks to alla involved.

And further more Embarcadero RAD's are easier but not really knowledgeable. It is a bit like "Kylix" whicj I bought some 15 years ago. Did it work? In any practical sense the answer is NO.

Whatever the use for "laz4android" is, ...I'll have to try to figure out.

When laztoapk arrives in pre-release, not alpha or beta, I'm interested.

Want to thank all for kind replies and general replies.

/Kamau

Leledumbo

  • Hero Member
  • *****
  • Posts: 8310
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android agan...
« Reply #7 on: May 08, 2015, 02:02:00 pm »
Don't attempt Android applications from Lazarus!
Let me complete that: if you're not ready for it (i.e. willing to read, understand and follow some documents). Otherwise, just go for it! Setting up the environment is only required once and is actually simple if you know some basic OS configuration (mainly manipulating environment variable, and perhaps symlinks to make your coding life better). After that, it's no different than building for desktop, minus debugging.

Kamau

  • Jr. Member
  • **
  • Posts: 67
  • Old Delphi programmer
Re: Android agan...
« Reply #8 on: May 08, 2015, 03:30:40 pm »
I fear we are going off topic, but just consider the following.

People use tools and machines without being able to build them. Driving cars without knowledge about combustion engines and electronics.

People use sophisticated software to produce useful results without being able to make software. They don't have to learn the file structure of pdf, rtf, xml, doc, docx etc to save files from Word.

Docs and manuals are generally written by people who already know and the docs are intelligible to those who already know. Telling things most people don't need to know and using technical jargon which prompts the reader to read another doc first, etc. etc. Or by trial and horror messing up everything more and more :-)

What beginners need is step by step guidance and then afterwards they will understand the docs.

Even you say that, quote: "Setting up the environment is only required once"

Hence it must be possible collect the config files and supply them for the benefit of those who want to get started.

But of course nobody is forced to act as a teacher.

Have a good day.

Lazarus is still a wonderful RAD-IDE! All honour to all who contribute to this program.

/Kamau

Leledumbo

  • Hero Member
  • *****
  • Posts: 8310
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Android agan...
« Reply #9 on: May 08, 2015, 06:06:05 pm »
Actually, what I'm trying to say is: feel free to give up yourself, but don't let those who are willing to struggle harder than you give up so soon by saying:
Don't attempt Android applications from Lazarus!

Chronos

  • Full Member
  • ***
  • Posts: 214
    • PascalClassLibrary
Re: Android agan...
« Reply #10 on: May 08, 2015, 06:52:28 pm »
Quote
First you need to choose the architecture of the app. Since you didn't say anything about that, there are at least 4 architectures possible:

1> Java + Pascal Library (via JNI).
2> Pascal library with OpenGL graphics
3> Laz4Android
4> LCL-CustomDrawn

Main question here is: How to use FPC and Lazarus so you can build Android application similar to Linux or Windows applications. Just simply create application, hit build and get apk. Or as apk is more like deb, rpm and msi, at least get executable file which have to be then packaged using some "Deploy" action. In case of Delphi XE, building android application is as simple as changing target platform and rebuilding project which generates apk file. So I would say none of provided 1-4 architectures. Maybe that should be called "5> Native support".

I think this is definitive solution for which many of us are looking forward.

DelphiFreak

  • Sr. Member
  • ****
  • Posts: 251
    • Fresh sound.
Re: Android agan...
« Reply #11 on: May 08, 2015, 06:57:27 pm »
Hello Kamau

I have written a instruction pdf: http://sourceforge.net/projects/laztoapk/files/Lazarus%20and%20Android.pdf/download
It took my several hours to get this done.
I have uploaded a video: http://sourceforge.net/projects/laztoapk/files/laztoapk_video.mp4/download

What have you constributed to the community?

Linux Mint 19.1, Lazarus 2.0, Windows 7&10, Delphi 7, Delphi 10.3 Rio

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3541
Re: Android agan...
« Reply #12 on: May 08, 2015, 10:10:23 pm »
In case of Delphi XE, building android application is as simple as changing target platform and rebuilding project which generates apk file. So I would say none of provided 1-4 architectures.

Maybe that should be called "5> Native support".

Not really. The list was of architectures of the software. Great support for a particular architecture does not constitute a 5th option, one would have to select one of the 4 architectures and build a installer with great support for it.

I guess it should be possible to make a add-on installer which includes the necessary parts of the Android SDK and Android NDK.

I don't have time for it, but I can help anyone wishing to do so.

In the past I created a VirtualBox VM Image with everything already setup so that people can have as easy as possible APK generation. But as time went on it became obsolete since it uses old Lazarus sources and old FPC version.

Likewise any such Delphi-like solution which includes parts of the SDK and NDK will become obsolete in a few years, since Android changes fast.

Also, how will you debug your app without "adb logcat"? And how will you have "adb" without the FULL Android SDK? And if you have to install the Android SDK separately, its no longer a 1-click process =)

How will you monetize your app without the extra AdSense from the FULL Android SDK? If you need to install this separately, its no longer a 1-click process =)

How does Delphi solve these 2 problems?

I think that multiple steps to configure are no problem if there are easy step-by-step instructions for doing it. I already made such instructions in the past, but a long time ago, and they need updating. I'll try to put in the wiki step-by-step instructions of my latest method of generating APKs, but I'm really with zero free time lately....
« Last Edit: May 08, 2015, 10:12:45 pm by felipemdc »

Kamau

  • Jr. Member
  • **
  • Posts: 67
  • Old Delphi programmer
Re: Android agan...
« Reply #13 on: May 09, 2015, 06:53:02 am »
Once again thanks for sharing your knowledge and experience with us. Here are a few comments as response from my side. Hopefully not totally irrelevant:

1. I don't think it is necessary to create a one step solution. As long as the steps are intuitive and easy to follow.

2. Programming "Studios" like Xamarin and Titanium require the download of SDK. In the case of Xamarin also NDK must be downloaded.

3. Programs like Eclipse and IntelliJ IDEA are of course possible to use, but the great and major advantage in Lazarus is the ease at which one can design forms and create events responding to inputs and clicks etc, then add the necessary code.

4. Android devices, like tablets are increasingly used in companies. There is a "need" for applications which work both on PC's and tablets. This often concerns applications which will not be marketed, only internally used. No monetizing needed.

5. Obviously there is some competition for Android at the moment. We don't yet know how Windows 10 and Tizen will be adopted. This makes it less evident where to spend "free time".

/Kamau

Chronos

  • Full Member
  • ***
  • Posts: 214
    • PascalClassLibrary
Re: Android agan...
« Reply #14 on: May 09, 2015, 10:23:25 am »
In case of Delphi XE, building android application is as simple as changing target platform and rebuilding project which generates apk file. So I would say none of provided 1-4 architectures.

Maybe that should be called "5> Native support".

Not really. The list was of architectures of the software. Great support for a particular architecture does not constitute a 5th option, one would have to select one of the 4 architectures and build a installer with great support for it.

But these "architectures" are not all possible solutions. I would say native for android means binary code for java virtual machine so compile everything to JVM code and you need add 5> option to the list.
1> Java + Pascal Library (via JNI).
2> Pascal library with OpenGL graphics
3> Laz4Android
4> LCL-CustomDrawn

1. I don't think it is necessary to create a one step solution. As long as the steps are intuitive and easy to follow.

Let's imagine that you buy Delphi XE and install it to your machine. Then you want to create Win32 application. You would expect to hit F9 key and see your application running. But instead of that they would provide you 10 page tutorial with many steps what you have to download, execute, copy, write, update, configure manually to be able to execute hello world application. I don't think such solution could be justified simply by saying "we don't have problem with multiple steps tutorials". And you can multiply this effect if you use more computers for development. I am using Lazarus from 3 computers.

It is possible to implement good Android support. It is not simple and it would take huge amount of time which nobody is currently willing to sacrifice.

I tried to rewrite one tutorial from forum to wiki http://wiki.freepascal.org/Android_tutorial and it somehow worked under Windows after few hours of effort. I was able to create and run android simple application with label and button, nothing complex. Then I tried to rewrite same tutorial for Linux as Xubuntu is my primary system and I had to give up. It was too complicated and there were various error messages and incompatibilities. As long as Lazarus is not officially supporting Android it will be still pain in the ass to make it run. Did I heard "write once, compile anywhere"? I want compile my application for and on Android. I am just kidding :)

I hope one day a hero will come and provides us compiler and IDE with native Android support so we would create fancy Android applications and be able to offer great mature applications on Google Play...

 

TinyPortal © 2005-2018