Sign in Join
Wiki copytemporary

LAMW install linux fpcupdeluxe: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Install LAMW and Android Development Environment on Linux using [fpcupdeluxe](https://wiki.freepascal.org/fpcupdeluxe)
22
33See also
44
5-`Forum Post: `[`https://forum.lazarus.freepascal.org/index.php?topic=40750`](https://forum.lazarus.freepascal.org/index.php?topic=40750)\
6-`For Windows How-To see here:  `[`https://wiki.freepascal.org/LAMW_install_windows_fpcupdeluxe`](https://wiki.freepascal.org/LAMW_install_windows_fpcupdeluxe)
5+```text
6+Forum Post: https://forum.lazarus.freepascal.org/index.php?topic=40750
7+For Windows How-To see here: https://wiki.freepascal.org/LAMW_install_windows_fpcupdeluxe
8+```
79
8-[`https://wiki.freepascal.org/LAMW`](https://wiki.freepascal.org/LAMW)\
9-[`https://github.com/jmpessoa/lazandroidmodulewizard`](https://github.com/jmpessoa/lazandroidmodulewizard)\
10-[`https://wiki.freepascal.org/fpcupdeluxe`](https://wiki.freepascal.org/fpcupdeluxe)\
11-[`https://github.com/LongDirtyAnimAlf/fpcupdeluxe`](https://github.com/LongDirtyAnimAlf/fpcupdeluxe)
10+```text
11+https://wiki.freepascal.org/LAMW
12+https://github.com/jmpessoa/lazandroidmodulewizard
13+https://wiki.freepascal.org/fpcupdeluxe
14+https://github.com/LongDirtyAnimAlf/fpcupdeluxe
15+```
1216
1317Known Issues
1418
15-`As of 2023-Nov-21, this error is still happening:`\
16-[`https://forum.lazarus.freepascal.org/index.php/topic,21919.msg441567.html#msg441567`](https://forum.lazarus.freepascal.org/index.php/topic,21919.msg441567.html#msg441567)
19+```text
20+As of 2023-Nov-21, this error is still happening:
21+https://forum.lazarus.freepascal.org/index.php/topic,21919.msg441567.html#msg441567
22+```
1723
18-`Manjaro / Arch Linux: As of 2023-May-22 installing on Manjaro works,`\
19-`and can be used for building a project but there is an issue`\
20-`with a workaround:`\
21-` * Lazarus Menu "Run" | "[LAMW] Build Android Apk and Run" fails`\
22-`   - Instead use "Run" | "Build" and if the build is successful open a terminal`\
23-`     in the project folder and run ./gradle-local-build.sh to build the APKs`
24+```text
25+Manjaro / Arch Linux: As of 2023-May-22 installing on Manjaro works,
26+and can be used for building a project but there is an issue
27+with a workaround:
28+ * Lazarus Menu "Run" | "[LAMW] Build Android Apk and Run" fails
29+ - Instead use "Run" | "Build" and if the build is successful open a terminal
30+ in the project folder and run ./gradle-local-build.sh to build the APKs
31+```
2432
2533Motivation
2634
27-`Needed simple instructions to get an up-to-date Android build environment setup on Linux.`\
28-`Thanks to other developers for sharing their hard work, utilities, and helpful information.`
35+```text
36+Needed simple instructions to get an up-to-date Android build environment setup on Linux.
37+Thanks to other developers for sharing their hard work, utilities, and helpful information.
38+```
2939
3040Everything is self-contained under the "\$BASE\android" folder
3141
32-`($BASE defaults to the user's home folder)`\
33-`$BASE/android/sdk  (android sdk and build tools)`\
34-`$BASE/android/sdk/ndk-bundle  (android ndk)`\
35-`$BASE/android/fpcupdeluxe_app  (FPCUPdeluxe installer)`\
36-`$BASE/android/projects  (default LAMW projects folder)`\
37-`$BASE/android/fpc-lazarus  (FPC, Lazarus built w/ LAMW)`\
38-`$BASE/android/fpc-lazarus/ccr/lamw  (LAMW files)`\
39-`$BASE/android/fpc-lazarus/ccr/lamw-gradle  (gradle build tool)`\
40-`$BASE/android/fpc-lazarus/ccr/lamw/demos (LAMW demo projects)`
42+```text
43+($BASE defaults to the user's home folder)
44+$BASE/android/sdk (android sdk and build tools)
45+$BASE/android/sdk/ndk-bundle (android ndk)
46+$BASE/android/fpcupdeluxe_app (FPCUPdeluxe installer)
47+$BASE/android/projects (default LAMW projects folder)
48+$BASE/android/fpc-lazarus (FPC, Lazarus built w/ LAMW)
49+$BASE/android/fpc-lazarus/ccr/lamw (LAMW files)
50+$BASE/android/fpc-lazarus/ccr/lamw-gradle (gradle build tool)
51+$BASE/android/fpc-lazarus/ccr/lamw/demos (LAMW demo projects)
52+```
4153
4254Versions Tested
4355
44-`xubuntu-23.04-minimal-amd64`\
45-`manjaro-xfce-22.1.2-minimal-230518-linux61 (not tested yet)`
56+```text
57+xubuntu-23.04-minimal-amd64
58+manjaro-xfce-22.1.2-minimal-230518-linux61 (not tested yet)
59+```
4660
47-`Android Command-Line Tools for Linux build 9477386`\
48-`OpenJDK 11.0.19`\
49-`Android SDK/API Level 31 (Android 12) (also tested API level 33 / Android 13)`\
50-`Android NDK revision 22`\
51-`Gradle 6.8.3 (installed automatically by FPCUPdeluxe)`
61+```text
62+Android Command-Line Tools for Linux build 9477386
63+OpenJDK 11.0.19
64+Android SDK/API Level 31 (Android 12) (also tested API level 33 / Android 13)
65+Android NDK revision 22
66+Gradle 6.8.3 (installed automatically by FPCUPdeluxe)
67+```
5268
53-`FPCUPdeluxe ver 2.4.0a`\
54-`FPC stable v3.2.2`\
55-`Lazarus stable v2.2.6`
69+```text
70+FPCUPdeluxe ver 2.4.0a
71+FPC stable v3.2.2
72+Lazarus stable v2.2.6
73+```
5674
57-`32-bit CPU Target: ARMv7a + VFPv3 (hardware floating point)(last testing was 2023-May)`\
58-`64-bit CPU Target: Aarch64 (this always uses hardware floating point)`
75+``` pascal
76+32-bit CPU Target: ARMv7a + VFPv3 (hardware floating point)(last testing was 2023-May)
77+64-bit CPU Target: Aarch64 (this always uses hardware floating point)
78+```
5979
6080## Main steps begin here
6181
62-``\
63-`Open a terminal and run the commands below.  I recommend running them one`\
64-`at a time in order to verify the results before moving on to the next step.`
82+```text
6583
84+Open a terminal and run the commands below. I recommend running them one
85+at a time in order to verify the results before moving on to the next step.
86+```
87+
6688``` bash
6789#!/usr/bin/env bash
6890# Setup Android Development Environment on Linux (FPCUPdeluxe / LAMW)
6991# Tested on
7092# xubuntu-23.04-minimal-amd64
7193# manjaro-xfce-22.1.2-minimal-230518-linux61 (not tested yet)
7294# Tested demo "AppHelloWord" aarch64 apk on Pixel 7 Android 13
7395# Targets: 64-bit Aarch64 (32-bit ARMv7a should work, but was not tested at this time)
7496# 2023-Nov-21 ver 2.1
7597
7698BASE="$HOME" #change this if you want to install to a different location
7799
78100# Install libraries and tools (Ubuntu based distros only)
79101sudo apt update
80102sudo apt install -y libx11-dev libgtk2.0-dev libgdk-pixbuf2.0-dev libcairo2-dev libpango1.0-dev libxtst-dev libatk1.0-dev libghc-x11-dev freeglut3-dev
81103sudo apt install -y git make build-essential gdb zip unzip unrar p7zip-full wget
82104sudo apt install -y openjdk-11-jdk android-tools-adb
83105
84106# Install libraries and tools (Arch Linux based distros only)
85107# uncomment these if using an Arch Linux based distro
86108#sudo pacman -Syu
87109#sudo pacman -S --needed libx11 gtk2 gdk-pixbuf2 cairo pango libxtst atk freeglut
88110#sudo pacman -S --needed git make gdb zip unzip unrar p7zip wget
89111#sudo pacman -S --needed android-tools jdk11-openjdk
90112
91113# download and extract Android SDK Command Line Tools for Linux
92114# from https://developer.android.com/studio/#downloads
93115mkdir -p "$BASE/android/sdk/cmdline-tools"
94116cd "$BASE/android/sdk/cmdline-tools"
95117wget "https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip"
96118unzip "commandlinetools-linux-9477386_latest.zip"
97119rm "commandlinetools-linux-9477386_latest.zip"
98120mv cmdline-tools tools
99121
100122# Install SDK packages and NDK
101123cd "$BASE/android/sdk/cmdline-tools/tools/bin"
102124yes | ./sdkmanager --licenses
103125# (Note: to view a list of available packages use ./sdkmanager --list)
104126# (a handy reference for API / SDK levels and Android version: https://apilevels.com/)
105127./sdkmanager "platforms;android-31" "build-tools;31.0.0" "tools" "ndk;22.1.7171670" "extras;android;m2repository"
106128# Android sdk for api level 33 also was tested and works
107129#./sdkmanager "platforms;android-33" "build-tools;33.0.2" "tools" "ndk;22.1.7171670" "extras;android;m2repository"
108130
109131# Download FPCUPdeluxe from https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/latest
110132# (tested with version 2.4.0a)
111133mkdir "$BASE/android/fpcupdeluxe_app"
112134cd "$BASE/android/fpcupdeluxe_app"
113135wget "https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/v2.4.0a/fpcupdeluxe-x86_64-linux"
114136chmod +x fpcupdeluxe-x86_64-linux
115137echo "[General]" > fpcupdeluxe.ini
116138echo "InstallDirectory=$BASE/android/fpc-lazarus" >> fpcupdeluxe.ini
117139./fpcupdeluxe-x86_64-linux
118140
119141# Using the FPCUPdeluxe GUI
120142# (The install path is already set to: /home/[your_user]/android/fpc-lazarus)
121143#
122144# 1) At the bottom of the main Window, click the "LAMW" button
123145#
124146# As of 2023-Nov-21, this installs stable FPC (3.2.2), stable Lazarus (v2.2.6), cross
125147# compilers for arm/android and aarch64/android, gradle v6.8.3, and latest LAMW from git.
126148#
127149# 2) (Optional) On module tab click the "OPM" button to install Online Package Manager.
128150# 3) Close FPCUPdeluxe
129151
130152# Change name for the desktop shortcut
131153mv "$(xdg-user-dir DESKTOP)/fpcup-Lazarus_fpc-lazarus.desktop" "$(xdg-user-dir DESKTOP)/Lazarus-LAMW.desktop"
132154sed -i "/^Name=/c\Name=Lazarus-LAMW" "$(xdg-user-dir DESKTOP)/Lazarus-LAMW.desktop"
133155
134156# Create a directory for android projects
135157mkdir -p "$BASE/android/projects"
136158
137159# Edit LAMW settings via the ini file
138160LAMWini="$BASE/android/fpc-lazarus/config_lazarus/LAMW.ini"
139161sed -i "/PathToWorkspace/c\PathToWorkspace=$BASE/android/projects" $LAMWini
140162echo "PathToAndroidSDK=$BASE/android/sdk" >> $LAMWini
141163echo "PathToAndroidNDK=$BASE/android/sdk/ndk/22.1.7171670" >> $LAMWini
142164echo "NDK=6" >> $LAMWini
143165
144166# After launching Lazarus-LAMW, confirm paths and settings are correct
145167# in the Tools | [LAMW] Android Module Wizard | Path Settings menu (CLICK OK)
146168```
147169
148170For new LAMW projects
149171
150-`for 32-bit:  ARMv7a + VFPv3 for Architecture/Instructions`\
151-`for 64-bit:  Aarch64 for Architecture/Instructions`\
152-`Min. Device API: 19  (Google recommended minimum SDK version)`\
153-`See here:  `[`https://android-developers.googleblog.com/2021/07/google-play-services-discontinuing-jelly-bean.html`](https://android-developers.googleblog.com/2021/07/google-play-services-discontinuing-jelly-bean.html)\
154-`Bug work-around: After creating a new project, save all, close lazarus, and re-open lazarus (it reloads the last open project)`\
155-`(this allows placement of controls on form without throwing an error - `[`SEE HERE`](https://forum.lazarus.freepascal.org/index.php/topic,21919.msg441567.html#msg441567)`)`
172+```text
173+for 32-bit: ARMv7a + VFPv3 for Architecture/Instructions
174+for 64-bit: Aarch64 for Architecture/Instructions
175+Min. Device API: 19 (Google recommended minimum SDK version)
176+See here: https://android-developers.googleblog.com/2021/07/google-play-services-discontinuing-jelly-bean.html
177+Bug work-around: After creating a new project, save all, close lazarus, and re-open lazarus (it reloads the last open project)
178+(this allows placement of controls on form without throwing an error - SEE HERE)
179+```
156180
157181For demo LAMW projects
158182
159-`(Project | Open Project) Open the controls.lpi file in the demo project jni folder`\
160-`Bug work-around 1: File | Save All. Close lazarus, and re-run lazarus (by default it opens the last project).`\
161-`for 32-bit:  Change LAMW project options | Min SDK: 19 and Build tab | Chipset: ARMv7a+VFPv3`\
162-`for 64-bit:  Change LAMW project options | Min SDK: 19 and Build tab | Chipset: Aarch64`\
163-`Bug work-around 2: Delete the custom options at Project | Project Options | Custom Options.`\
164-`File | Save All`\
165-`Perform a Run | Clean up and Build`\
166-`Open a terminal in the project folder and run: ./gradle-local-build.sh`\
167-`(or Perform a Run | Build Clean up and Build)`\
168-`If successful, the apk files will be in`\
169-`  [project_folder]/build/outputs/apk/debug   #if using a real device, test with this one`\
170-`  [project_folder]/build/outputs/apk/release`
183+```text
184+(Project | Open Project) Open the controls.lpi file in the demo project jni folder
185+Bug work-around 1: File | Save All. Close lazarus, and re-run lazarus (by default it opens the last project).
186+for 32-bit: Change LAMW project options | Min SDK: 19 and Build tab | Chipset: ARMv7a+VFPv3
187+for 64-bit: Change LAMW project options | Min SDK: 19 and Build tab | Chipset: Aarch64
188+Bug work-around 2: Delete the custom options at Project | Project Options | Custom Options.
189+File | Save All
190+Perform a Run | Clean up and Build
191+Open a terminal in the project folder and run: ./gradle-local-build.sh
192+(or Perform a Run | Build Clean up and Build)
193+If successful, the apk files will be in
194+ [project_folder]/build/outputs/apk/debug #if using a real device, test with this one
195+ [project_folder]/build/outputs/apk/release
196+```
171197
172198Optional script to create terminal launcher for command line work
173199
174200``` bash
175201#Create shell script and desktop shortcut
176202$BASE = "$HOME" #change this if you installed to a different location above
177203
178204LAMWini="$BASE/android/fpc-lazarus/config_lazarus/LAMW.ini"
179205# Note: the following lines must be copy/pasted as one line, starting at "cat" and ending at "EOF"
180206cat <<EOF > $BASE/android/set_dev_environment
181207#!/bin/sh
182208# Setup environment for fpc / lazarus / android command line work
183209
184210FPC_PATH="$BASE/android/fpc-lazarus/fpc/bin/x86_64-linux"
185211LAZ_PATH="$BASE/android/fpc-lazarus/lazarus"
186212
187213export PPC_CONFIG_PATH=\${FPC_PATH}
188214export PATH=\${FPC_PATH}:\${LAZ_PATH}:\${PATH}
189215
190216export ANDROID_SDK_ROOT="${BASE}/android/sdk"
191217export GRADLE_HOME="$(awk -F '=' '/PathToGradle/{print $NF}' $LAMWini)"
192218export PATH=\${PATH}:\${GRADLE_HOME}/bin
193219
194220cd "$BASE/android/projects"
195221exec /bin/bash
196222EOF
197223chmod +x $BASE/android/set_dev_environment
198224
199225# Note: the following lines must be copy/pasted as one line, starting at "cat" and ending at "EOF"
200226cat <<EOF > "$(xdg-user-dir DESKTOP)/Android-Command-Line.desktop"
201227[Desktop Entry]
202228Type=Application
203229Icon=utilities-terminal
204230Exec=$BASE/android/set_dev_environment
205231Name=Android-Command-Line
206232Terminal=true
207233StartupNotify=false
208234EOF
209235chmod +x "$(xdg-user-dir DESKTOP)/Android-Command-Line.desktop"
210236```
211237
212238Changes
213239
214-`2023-Nov-21 ver 2.1`\
215-` Add p7zip to package installation (fpcupdeluxe wants to use it)`\
216-` Update FPCUPdeluxe version to 2.4.0a`\
217-` Also tested Android SDK api level 33`\
218-` Only tested on xubuntu-23.04-minimal-amd64 with aarch64 build`
240+```text
241+2023-Nov-21 ver 2.1
242+ Add p7zip to package installation (fpcupdeluxe wants to use it)
243+ Update FPCUPdeluxe version to 2.4.0a
244+ Also tested Android SDK api level 33
245+ Only tested on xubuntu-23.04-minimal-amd64 with aarch64 build
246+```
219247
220-`2023-May-22 ver 2.0`\
221-`  Added LAMW bug work-arounds for two cases:`\
222-`    1) Directly after creating a new project, save the project, close Lazarus, and re-open.`\
223-`    2) Directly after opening a demo project, save the project, close Lazarus, and re-open.`\
224-`    `\
225-`  Tested on more distro versions`\
226-`    xubuntu-20.04.6-desktop-amd64`\
227-`    xubuntu-22.04.2-desktop-amd64 (minimal install)`\
228-`    xubuntu-23.04-minimal-amd64 (NOTE: I will not usually test on non-LTS versions)`\
229-`    manjaro-xfce-22.1.2-minimal-230518-linux61 (based on arch linux)`\
230-`    `\
231-`  Manjaro does not have special issues with changing the LAMW project chipset - remove previous comment`\
232-`  Don't explicitly install freeglut3 (it gets pulled in if needed by freeglut3-dev)`\
233-`  Remove subversion from install packages (fpc and lazarus both use git now)`\
234-`  Remove apache-ant from pacman (arch linux) install (fpcupdeluxe installs a private copy)`\
235-`  Testing with updated software components:`\
236-`    fpcupdeluxe 2.2.0r`\
237-`    OpenJDK ver 11.0.19`\
238-`    Lazarus stable v2.2.6`
248+```text
249+2023-May-22 ver 2.0
250+ Added LAMW bug work-arounds for two cases:
251+ 1) Directly after creating a new project, save the project, close Lazarus, and re-open.
252+ 2) Directly after opening a demo project, save the project, close Lazarus, and re-open.
253+
254+ Tested on more distro versions
255+ xubuntu-20.04.6-desktop-amd64
256+ xubuntu-22.04.2-desktop-amd64 (minimal install)
257+ xubuntu-23.04-minimal-amd64 (NOTE: I will not usually test on non-LTS versions)
258+ manjaro-xfce-22.1.2-minimal-230518-linux61 (based on arch linux)
259+
260+ Manjaro does not have special issues with changing the LAMW project chipset - remove previous comment
261+ Don't explicitly install freeglut3 (it gets pulled in if needed by freeglut3-dev)
262+ Remove subversion from install packages (fpc and lazarus both use git now)
263+ Remove apache-ant from pacman (arch linux) install (fpcupdeluxe installs a private copy)
264+ Testing with updated software components:
265+ fpcupdeluxe 2.2.0r
266+ OpenJDK ver 11.0.19
267+ Lazarus stable v2.2.6
268+```
239269
240-`2023-Feb-06 ver 1.9`\
241-` Add support for Arch Linux based distros`\
242-` Test on Manjaro 22.0`\
243-` Add known issues based Manjaro testing`
270+```text
271+2023-Feb-06 ver 1.9
272+ Add support for Arch Linux based distros
273+ Test on Manjaro 22.0
274+ Add known issues based Manjaro testing
275+```
244276
245-`2023-Feb-06 ver 1.8`\
246-` Use $BASE for installation directory (defaults to $HOME)`\
247-` Android Command-Line Tools for Linux build 9477386`\
248-` OpenJDK 11.0.17`\
249-` Gradle 6.8.3 (installed automatically by FPCUPdeluxe)`\
250-` FPCUPdeluxe ver 2.2.0n`\
251-` Lazarus stable v2.2.4`
277+```text
278+2023-Feb-06 ver 1.8
279+ Use $BASE for installation directory (defaults to $HOME)
280+ Android Command-Line Tools for Linux build 9477386
281+ OpenJDK 11.0.17
282+ Gradle 6.8.3 (installed automatically by FPCUPdeluxe)
283+ FPCUPdeluxe ver 2.2.0n
284+ Lazarus stable v2.2.4
285+```
252286
253287---
254288*From the Free Pascal wiki, page "LAMW install linux fpcupdeluxe", as it stood on 2023-12-02 after a change by WayneSherman, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history