Android agan... lazarus / 43-Android ---------------------------------------------------------------------- Kamau · 2015-05-05 10:17 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 · 2015-05-05 13:03 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_O penGL_example For architecture 3 there is: http://wiki.lazarus.freepascal.org/Android_tutorial QuoteIs 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 ---------------------------------------------------------------------- Kamau · 2015-05-05 13:16 Thank you for the reply. I will check your proposals. /Kamau ---------------------------------------------------------------------- DelphiFreak · 2015-05-06 17:06 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 ---------------------------------------------------------------------- Kamau · 2015-05-07 04:38 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 · 2015-05-07 16:11 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/apkmanage rmain.pas See methods DetectInstalledNDKPlatforms and DetectInstalledSDKBuildTools. Regards, Sam ---------------------------------------------------------------------- Kamau · 2015-05-08 07:47 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 · 2015-05-08 12:02 Quote from: Kamau on May 08, 2015, 09:47:07 amDon'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 · 2015-05-08 13:30 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 · 2015-05-08 16:06 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: Quote from: Kamau on May 08, 2015, 09:47:07 amDon't attempt Android applications from Lazarus! ---------------------------------------------------------------------- Chronos · 2015-05-08 16:52 QuoteFirst 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 · 2015-05-08 16:57 Hello Kamau I have written a instruction pdf: http://sourceforge.net/projects/lazt oapk/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/file s/laztoapk_video.mp4/download What have you constributed to the community? ---------------------------------------------------------------------- felipemdc · 2015-05-08 20:10 Quote from: Chronos on May 08, 2015, 06:52:28 pmIn 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.... ---------------------------------------------------------------------- Kamau · 2015-05-09 04:53 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 · 2015-05-09 08:23 Quote from: felipemdc on May 08, 2015, 10:10:23 pmQuote from: Chronos on May 08, 2015, 06:52:28 pmIn 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 Quote from: Kamau on May 09, 2015, 06:53:02 am1. 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... ---------------------------------------------------------------------- Leledumbo · 2015-05-09 08:38 Quote from: Chronos on May 09, 2015, 10:23:25 amI 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. So, haven't you read this and that? (Note that the latter is a bit outdated, there's no need to patch lazarus and fpc if you use recent revisions). ---------------------------------------------------------------------- Chronos · 2015-05-09 09:16 Quote from: Leledumbo on May 09, 2015, 10:38:21 amQuote from: Chronos on May 09, 2015, 10:23:25 amI 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. So, haven't you read this and url=http://wiki.freepascal.org/FPC_JVM_Android_Development]that[/url]? (Note that the latter is a bit outdated, there's no need to patch lazarus and fpc if you use recent revisions). Yes, I am aware of the wiki page. But it looks more like research project now then ready to use solution. I don't want to patch FPC as it is way too complicated on linux. And there are too many manual steps which can go wrong. This is one of my problem that I spend too much time solving problems with tools so as consequence don't have enough time to create applications. This is even more significant in payed job where using Delphi taken much less maintenance time in comparison to at that time unfinished Lazarus 0.9.xxx. Simply I don't want to use anything what author wasn't dare to mark as stable. Even in stable software there are bugs. But if software is marked as stable it means at least that API and user interface will not change much until next stable release and software is at least somehow tested in comparison to trunk/nightly/daily builds. So long story short: make it stable and "one click" solution and I will not be only one who will try to use it. Are there demonstration applications (apk files) somewhere? ---------------------------------------------------------------------- Leledumbo · 2015-05-09 10:04 Quote from: Chronos on May 09, 2015, 11:16:48 amBut it looks more like research project now then ready to use solution. It is. The fact that it's a part of trunk only means that it's still in development Quote from: Chronos on May 09, 2015, 11:16:48 amSo long story short: make it stable and "one click" solution and I will not be only one who will try to use it. Wait for FPC 3.0.0 and it might happen. Quote from: Chronos on May 09, 2015, 11:16:48 amAre there demonstration applications (apk files) somewhere? Just the apk? How about mine? It uses LCL custom drawn which I don't use anymore in favor of LazAndroidModule due to incompleteness and non-native look and feel. There's another one with LazAndroidModule but it talks to 3rd party web service which I think is already shut down, which means other than the main screen, everything else won't work. Here's one from $(LazarusDir)/examples/androidlcl. My arm- android compiler is compiled with ARM_HF these days because I'm currently playing with Raspberry Pi, which doesn't seem to work well on Android devices including the emulator. ---------------------------------------------------------------------- Kamau · 2015-05-09 10:27 In 2016 I am planning (God willing) to leave the equatorial regions of Africa, where MB's are still paid bit by bit, and go for a visit to my second home country Holland where I have access to unlimited high speed internet and the possibility to buy a Raspberry-Pi.... which I plan to do. I realize it is a bit off topic, but can you please tell more about te shortcomings of Raspberry-Pi? I had hoped to be able to compile Lazarus on an arm platform and compile native applications. (Like I do now in various other Linux versions on 32 and 64 bit.) And maybe even this would be an alternative? http://nos.nl/artikel/2034632-deze-computer-kost-maar-9-dollar.html Just want to stress once more how appreciative and grateful I am for Lazarus! My last official Delphi was Delphi6. Retired, doing other things with my time and resources, although still programming now and then, not willing to waste money on expensive professional commercial software when it can better be used for needy children and their education. As somebody asked about my contributions to this community... Most likely not of any importance. /Kamau ---------------------------------------------------------------------- DonAlfredo · 2015-05-09 11:22 Holland + Raspberry Pi(2) + FPC/Lazarus go together very well !! I can tell you from personal experience  My advice: go for cross-compiling. Makes life a lot easier. ---------------------------------------------------------------------- Kamau · 2015-06-26 04:26 Quote from: DelphiFreak on May 08, 2015, 06:57:27 pmHello Kamau, What have you constributed to the community? We probably live under very different conditions. Here at the equator not everything is as easy and cheap as in Europe with unlimited fast broadband. But I had the fortunate possibility to download everything and install all again. Making a very somple program with an edit field, a button and a label. Pressing the button copies the edit text to the label caption. An apk-file is created when the project is compiled, but when I try to install it, nothing is installed. Looking in the archive I can see a rather big library file but no executable. Any suggestion on what I am missing? /Kamau ---------------------------------------------------------------------- renabor · 2015-06-26 05:40 @kamau you can try following my step by step guide in order to obtain a fully functional linux box with lazarus, ready to code for android apk http://forum.lazarus.freepascal.org/index.php/topic,21919.msg168526.ht ml#msg168526 ---------------------------------------------------------------------- DelphiFreak · 2015-06-26 09:56 Hello kamau, yes we live really under very different conditions. The time I have to sit in front of my computer is very limited. But about your problem. Could you tell me which OS you use and maybe also attach the whole project-folder as a zip-file? I will then try to build it here and compare it with the output of my build. Regards, Sam ---------------------------------------------------------------------- Kamau · 2015-06-26 13:25 Thank you, I am trying it on Windows 8.1 The zip-file is attached if such big attachments are allowed.... Got the message that the zip is too big. Do you really need the total directory? Unzipped 11.4 MB, zipped 5.5 MB If so I could upload it to my server and send you the link, preferably in direct mail. I sent you a PM with the link. /Kamau ---------------------------------------------------------------------- DelphiFreak · 2015-06-26 14:10 Ok, I got your file. First, sorry I have no windows 8. I did compare your files with my files and here are the differences: In file "generate_debug_key.bat" and "build_debug_apk.bat" I see that you have android-12 and I have android-16 Your file: SET APK_SDK_PLATFORM="c:\laztoapk\downloads\android-sdk- windows\platforms\android-12" My file:    SET APK_SDK_PLATFORM="C:\laztoapk\downloads\android-sdk- windows\platforms\android-16" Another potential troublemaker could be the JDK-path. In my environment, the jdk  is located in C:\Programme\Java\jdk1.8.0_31\bin which does not contain any spaces. In your case its located in "Program Files" which could give troubles within the batch-files. Sorry I need to go now. Maybe I have more timer later this evening. Sam ---------------------------------------------------------------------- Kamau · 2015-06-27 07:05 Thank you for the reply. I have several Android devices and thought that an earlier issue would be more compatible. Additionally, I did not select (as far as I can remember) for any particular issue. If you recommend 16, then I'll try that. Would you also recommend that I install the program on earlier Windows version. I saw that you do not use W8 and your info makes me believe that you may even be on a version before XP. Just recommend and I'll install that version on one of my computers. If you prefer to answer in your native language you can do so in a PM. I have full understanding of the German language. (You may use Swedish, English, German, Dutch or Kiswahili.) /Kamau