Setting up for Andoid easy to mess up, or is it just me? lazarus / 43-Android ---------------------------------------------------------------------- Rbart · 2023-11-17 16:54 Hi, As a very Newbie..searching for a new way to develop programs and apps when I able retire at 60 next year. The idea was very appealing to be able to write code once for all platforms. So I started a journey, learn Pascal and Lazarus and enter a new world. Setting up Lazarus was going ok. For Android it's a different story. I found it confusing. You need to set up a different version of Lazarus or is the current version going to be influenced? I run a dual boot Linux with windows. So to be 'save' I used the windows side to try out Lazarus for android. LAMW didn't work with the new versions of Lazarus. So every thing went bad. But I saw there were two versions. Lazarus and LazAndroid after installing lazandroid. But nothing was working without LAMW, I guess? So I tryed the other option to install fpcupdeluxe on Linux. The setup was successful but Google wanted me to install an update. So I did that. So now I was able to build a GUI with a button and a textfield. Trying to run this, didn't work so I searched and found you need to set up an emulator. No succes at that neighter. In a forum I found someone suggesting you should install Android studio. I installed Android studio via a snap. I think that messed it up good. Can I stille save this situation? And get my attemps working is an emulator? Many thanks, Rbart ---------------------------------------------------------------------- Handoko · 2023-11-17 17:15 Hello Rbart, Welcome to the forum. I used LAMW and managed to generate Android APK to run on my Asus Intel processor mobile phone. I admit to say the installation process was a bit challenging for most people, especially setting up to toolchain for generating Intel (not ARM) Android binaries. But, I did it. I haven't used LAMW for a while for some reasons. But I am sure I will do Android programming again later. I just want to tell you: don't give up. Do you know how long the process I started to try LAMW until I really created the app to run on my phone? Almost a whole year. Yes, no joking. The documentation was poor, and if you had problem, no body could help you. Things are much easier now, more people get involved, LAMW and the documentation have improved a lot. If I can give you advice, I would say: - Read the documentation thoroughly: https://github.com/jmpessoa/lazandroidmodulewizard - It will be much easier to test your apk on a real phone, don't run it on any emulator because they are extremely slow. ---------------------------------------------------------------------- jmpessoa · 2023-11-17 17:24 Hi, Rbart! Can you try install on a real device? (In fact, nowadays to get an emulator you need a complete "Anddroi Studio" install) ---------------------------------------------------------------------- Rbart · 2023-11-17 17:50 Hi jmpessoa and Handoko, Thanks for the suggestions. I have an Android phone, that's a step. At this time I have to figure out how to install from Lazarus on it. Android studio I have installed on Linux that's where it went wrong with duplicate things errors. Neighter laz4android nor this Android studio is working now. Should I want to turn to this studio I could not. I guess they interfere with each other. I will try to get sence out of the documentation. I hope not having to spent a year to get a 'hello world' working. Better to learn Java and use the Android studio then. No, I find this idea with Lazarus a better challenge. I hope more people step in to this project. It has potential but also some real drawbacks. Thanks and greetings from Belgium, Rbart. ---------------------------------------------------------------------- Seenkao · 2023-11-18 04:22 Android Studio нужен только для отладки или запуска эмулятора. Для создания приложения достаточно установить LAWM, собрать проект и собрать APK-файл. Если ни чего не изменилось в последнее время. Google translate:   Android Studio is only needed for debugging or running the emulator. To create an application, you just need to install LAWM, build the project and build the APK file. If nothing has changed recently. ---------------------------------------------------------------------- Rbart · 2023-11-18 09:36 Hi Seenkao, Thing have changed. Lazarus current version does no work with the two years old version of LAMW. You can not rely on the guides here in 2023. They are outdated. I have build the APK but it  is giving me lot's of fails en errors. Maybe building the tools from scratch would be the only way left to get things up to date. I hope that it will work with the updates the system is asking for. The world will have to be patient a bit longer for my first 'Hello' in Android. Greeting Rbart ---------------------------------------------------------------------- Handoko · 2023-11-18 09:43 For security reasons, Google wants us to use the newer API versions. Have you followed the messages to update your SDK using the sdkmanager? That should fix your issue. ---------------------------------------------------------------------- Rbart · 2023-11-18 10:06 I did. But now it is asking again. I am getting all sorts of errors. Every thing I do seems to make things worse. ---------------------------------------------------------------------- Handoko · 2023-11-18 10:22 Did you get the error when compiling your own project? I mean, make sure you have installed LAMW and all the necessary things properly before starting your projects. In the LAMW folder, you can find some demos. Try to compile/build the demos and run them on your phone. If you're having problem building the demos to generate apks, that means you haven't install the LAMW correctly. If you can build the demos but can't or don't know to to make it to run your phone, try Googling the web "how to install apk on android". Android does not allow users to install apks that are not provided by Google/Play Store, you should enable this 'special app access' first. ---------------------------------------------------------------------- Rbart · 2023-11-18 10:52 LAMW is installed by fpcupdelux. I expected it to do the job. Try to open a demo gives me errors. Every thing gives errors. I give up for today. I'll look at it tommorow with a fresh mind. ---------------------------------------------------------------------- Handoko · 2023-11-18 10:57 Have you done these: sdkmanager --update sdkmanager "build=tools;32.0.02" "platforms;android-33" And did you get any errors running those commands above? ---------------------------------------------------------------------- Seenkao · 2023-11-18 14:21 Для LAWM не используйте последнюю версию Gradle. Уточните какая максимальная версия Gradle нужна для сборки проекта LAWM. Google translate:   For LAWM, do not use the latest version of Gradle. Check what maximum version of Gradle is needed to build the LAWM project. ---------------------------------------------------------------------- Rbart · 2023-11-19 09:17 Hi Handoko, There's no sdkmanager installed. I followed these guidelines: https://wiki.freepascal.org/LAMW_install_linux_fpcupdeluxe Hi Seenkao, Why not use the latest version of Gradle? I did not have a choosing of the version when installing. In LAWM it's version 6.8.3 I can't find what it is for Android studio. Can both Android studio and fpcupdelux or LAWM just share the same sources? ---------------------------------------------------------------------- Handoko · 2023-11-19 10:54 I don't Android programming currently, I can't be sure to tell you how to install LAMW and all the necessary things correctly. If you failed to install sdkmanager following that installation instruction, try this: https://developer.android.com/tools/sdkmanager Alternatively, you can try other options: https://github.com/jmpessoa/lazandroidmodulewizard I used Laz4Android (option a). This probably is the easiest, but as a Linux user, I had to set a Windows virtual machine first. Or you can try the option b and option d. ---------------------------------------------------------------------- Handoko · 2023-11-19 11:05 Okay, I think I know your problem now. Previously I said: Quote from: Handoko on November 18, 2023, 11:57:19 amsdkmanager --update sdkmanager "build=tools;32.0.02" "platforms;android-33" I forgot to tell you, for Linux users you have to add "./", so those commands should be: ./sdkmanager --update ./sdkmanager "build=tools;32.0.02" "platforms;android-33" ---------------------------------------------------------------------- Rbart · 2023-11-19 11:30 ./sdkmanager file or folder does not exist. Am I in the right folder? I can see a sdkmager. (see screenprint previous post) Maybe I should build from scratch using the old version from two years ago? Seems like the new versions won't work together very well. And then I still can't test anything unless I connect an external device. I am afraid the new Android studio will reject these old projects too. ---------------------------------------------------------------------- Handoko · 2023-11-19 11:39 In Windows, you just need to type the name of the program to run it. For example, you're in the folder that contains notepad.exe, to start the program you type this in the Command Prompt: notepad But in Linux, you have you add "./" in front of the program name. For example you're in same folder of the your program named myprog. To run it from Terminal (Linux calls it Terminal, Windows calls it Command Prompt) you type this: ./myprog Quote from: Rbart on November 19, 2023, 12:30:29 pm./sdkmanager file or folder does not exist. Am I in the right folder? I can see a sdkmager. (see screenprint previous post) sdkmanager is a program. You need to goto the folder first before you can run it. ---------------------------------------------------------------------- Rbart · 2023-11-19 15:26 I tryed on Windows with Laz4Android. Following this: https://github.com/jmpessoa/lazandroidmodulewizard 4) Go to Lazarus menu "Tools" --> "[LAMW] Android Module Wizard" --> "Build FPC Cross Android" and repeat the "Build and install" process once for each architecture. There is no [LAMW] Android Module Wizard ---------------------------------------------------------------------- Handoko · 2023-11-19 15:38 If you managed to install LAMW correctly, you can try: Lazarus main menu > New > There should be able to find LAMW related projects. ---------------------------------------------------------------------- Handoko · 2023-11-19 16:09 Quote from: Rbart on November 19, 2023, 12:30:29 pm./sdkmanager file or folder does not exist. Please use your Terminal and go to the location: ~/android/sd/cmdline-tools/tools/bin And then type: ls And please post the screenshot. --- I downloaded the SDK as mentioned by the installation guide in the link you gave, the sdkmanager was indeed inside the zip file. I unzipped the zip file and I could run sdkmanager. ---------------------------------------------------------------------- Rbart · 2023-11-20 11:48 So it was a different folder then the one mentioned in the warning. The sdkmanager is an empty file there. I tryed the update the 'right' folder but failed again to install the update. ---------------------------------------------------------------------- Handoko · 2023-11-20 14:27 You can try to run sdkmanager without any parameter: ./sdkmanager If I remember correctly, running sdkmanager without any parameter will cause it to start in GUI mode. There you can update necessary components easily. ---------------------------------------------------------------------- Seenkao · 2023-11-20 16:05 Android Studio установлен у вас? Если да, то вам надо через настройки Android Studio установить нужные параметры для SDKmanadger.   И, если у вас установлен Android Studio, то вам необходимо выполнить первые шаги по сборке простых проектов. - создайте простой проект на Android Studio (на просторах интернета много примеров для создания подобных примеров). - протестируйте данный проект на работоспособность. - при возникновении ошибок при сборке проекта или тестировании, необходимо их устранить (думаю есть много примеров по тому как работать с Android Studio и там же показано как исправлять основные ошибки).   Если всё хорошо работает, то можете начинать переходить на проекты FPC/Lazarus + LAWM.   Множество ошибок выскакивающих у вас, так же встречаются и при сборке проектов на Android Studio. Поэтому много ответов вы можете найти не здесь, а на других форумах или сайтах, где рассказывается о работе с проектами под Android. --------------------------------- Google translate:   Do you have Android Studio installed? If yes, then you need to set the necessary parameters for SDKmanadger through the Android Studio settings.   And, if you have Android Studio installed, then you need to complete the first steps to build simple projects. - create a simple project in Android Studio (there are many examples on the Internet for creating similar examples). - test this project for functionality. - if errors occur during project assembly or testing, you need to eliminate them (I think there are many examples on how to work with Android Studio and it also shows how to correct basic errors).    If everything works well, then you can start moving to FPC/Lazarus + LAWM projects.    Many errors that pop up for you also occur when building projects on Android Studio. Therefore, you can find many answers not here, but on other forums or sites that talk about working with projects for Android. ---------------------------------------------------------------------- Rbart · 2023-11-20 19:02 Hi Seenkao and Hondoko, Thanks for the information. Adroid studio works,  I even got the emulator working with a 'hello world'. Nothing slow about it. I am running it on a recent computer. Importing the projects from Lazarus is a different story. I will have to learn how Lazarus and LAWM is working to figure it out, if it's even possible to do so with all the old and new versions around. I was not expecting I was going to have to dig deeper in the IDE itself to get this working. Even if I get it to work. It is still a different version than Lazarus. It needs other controls from the Android bridge. So I would have to build a separet application for Android anyway. And still need Android studio to run it. Learn Java as well is probably not a bad idea. If Lazarus then still has advantages I'm not sure. So I will let it rest for a while. Have to go to work for the next 4 days, no energy in the evenings anymore like I was younger. @handoko The sdkmanager did not start. See attachments Greetings Rbart ---------------------------------------------------------------------- nobody.00 · 2023-11-20 22:05 your errors: marked try: ./sdkmanager "build-tools;33.0.2" "platforms;android-33" ---------------------------------------------------------------------- Handoko · 2023-11-21 10:41 Quote from: Rbart on November 20, 2023, 08:02:59 pmAdroid studio works,  I even got the emulator working with a 'hello world'. Nothing slow about it. I am running it on a recent computer. Glad to know you managed to make it works. And sorry, my previous comments weren't very helpful. Quote from: Rbart on November 20, 2023, 08:02:59 pmI was not expecting I was going to have to dig deeper in the IDE itself to get this working. Even if I get it to work. It is still a different version than Lazarus. It needs other controls from the Android bridge. So I would have to build a separet application for Android anyway. And still need Android studio to run it. Learn Java as well is probably not a bad idea. If Lazarus then still has advantages I'm not sure. This is Lazarus/Pascal forum, of course here they will tell you Lazarus+LAMW is better than Java+others for building Android applications.  You mentioned Java ... maybe you haven't know, Lazarus/FPC can build Java applications too: https://wiki.lazarus.freepascal.org/Lazarus_JVM One of Lazarus/FPC strength is cross compiling. I am building my cross platform OpenGL graphics engine that can be used on Windows, Linux and Android, it is a single project not 3 separate projects. I made use of Pascal conditional compilation: https://wiki.freepascal.org/Conditional_compilation LAMW Android components are not Lazarus native components, how can I 'merged' it with Windows/Linux components into a single project? Sure I do not merge all of them into a single file. But the OpenGL part is basically the same for all them, so the basic logic of my graphics engine (the OpenGL part) is shared and then I only need to write their platform depended 'things' into their own unit. It's not only in theory, actually I already have some code that works on Windows, Linux and Android. Unfortunately, I was busy and some issue with LAMW bugs, this project is temporary paused. Each software development tool has their own advantages and disadvantages. Which tool to use, is more depended on the programmer personal choice. If you're not familiar with Lazarus/Pascal, you may have better luck to use other software to build applications. I am not a Pascal/Lazarus fanatic, before I decided to use Lazarus I really have done some research and tried many other tools. I use Lazarus because I know its advantages: - Cross platform and cross compile - General purpose (I can build all kinds of program if I have the knowledge) - The generated binaries have good performance and relatively small in size - Readability source code, easy to debug and maintain - RAD (plenty of ready-to-used both visual and non-visual components) - Compile very fast You should not simply believe what I said, you have to do the research yourself. And about Android Bridges, as far as I know there is no documentation for them. But that shouldn't be a problem because all of them have example code, you can find them in the demos in the LAMW folder. ---------------------------------------------------------------------- Seenkao · 2023-11-21 13:09 nobody.00, это может не сработать, если человек не установил необходимые инструменты для SDKmanadger. Их сначала надо установить, а уже потом использовать.   При этом надо указать в AndroidManifest версию под которую собирается проект (если проект был подготовлен не в Android Studio). А если используется Gradle, а не Android Studio для сборки проекта, то необходимо настроить Gradle для сборки проекта под необходимую версию Android (и как я писал выше, надо установить необходимые инструменты). Google translate:   nobody.00, this may not work if the person has not installed the necessary tools for SDKmanadger. They must first be installed, and only then used.    You also need to indicate in the AndroidManifest the version for which the project is being built (if the project was not prepared in Android Studio). And if you use Gradle and not Android Studio to build the project, then you need to configure Gradle to build the project for the required version of Android (and as I wrote above, you need to install the necessary tools). ---------------------------------------------------------------------- WayneSherman · 2023-11-21 23:03 Quote from: Rbart on November 19, 2023, 10:17:37 amI followed these guidelines: https://wiki.freepascal.org/LAMW_install_linux_fpcupdeluxe These instructions have been updated.  The main stopper for me was needing to use the most recent version of FPCUpDeluxe.  Note, there are some quirks trying to open and build the demo projects.  See the instructions under heading "For demo LAMW projects" which shows the steps I used for building the demo project "AppHelloWord". ---------------------------------------------------------------------- Rbart · 2023-11-26 09:19 Hi All, Thank you all for the help. I learned a lot. I will need to dig deeper in this later on. Before a couple of weeks ago I didn't even know of the existance of Lazarus. I do think there's still a future for this 'dead' language. But it will need a lot of work to get around all the draw backs. A great project for my retirement days next year. Greetings, Rbart