Sign in Join
Wiki copytemporary

LAMW install linux fpcupdeluxe: what changed

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

Title: LAMW install linux fpcupdeluxe

OldNewLine
1+## Install LAMW and Android Development Environment on Linux using [fpcupdeluxe](https://wiki.freepascal.org/fpcupdeluxe)
2+
3+See also
4+
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)
7+
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)
12+
13+Known Issues
14+
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)
17+
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+
25+Motivation
26+
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.`
29+
30+Everything is self-contained under the "\$BASE\android" folder
31+
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)`
41+
42+Versions Tested
43+
44+`xubuntu-23.04-minimal-amd64`\
45+`manjaro-xfce-22.1.2-minimal-230518-linux61 (not tested yet)`
46+
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)`
52+
53+`FPCUPdeluxe ver 2.4.0a`\
54+`FPC stable v3.2.2`\
55+`Lazarus stable v2.2.6`
56+
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)`
59+
60+## Main steps begin here
61+
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.`
65+
66+``` bash
67+#!/usr/bin/env bash
68+# Setup Android Development Environment on Linux (FPCUPdeluxe / LAMW)
69+# Tested on
70+# xubuntu-23.04-minimal-amd64
71+# manjaro-xfce-22.1.2-minimal-230518-linux61 (not tested yet)
72+# Tested demo "AppHelloWord" aarch64 apk on Pixel 7 Android 13
73+# Targets: 64-bit Aarch64 (32-bit ARMv7a should work, but was not tested at this time)
74+# 2023-Nov-21 ver 2.1
75+
76+BASE="$HOME" #change this if you want to install to a different location
77+
78+# Install libraries and tools (Ubuntu based distros only)
79+sudo apt update
80+sudo 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
81+sudo apt install -y git make build-essential gdb zip unzip unrar p7zip-full wget
82+sudo apt install -y openjdk-11-jdk android-tools-adb
83+
84+# Install libraries and tools (Arch Linux based distros only)
85+# uncomment these if using an Arch Linux based distro
86+#sudo pacman -Syu
87+#sudo pacman -S --needed libx11 gtk2 gdk-pixbuf2 cairo pango libxtst atk freeglut
88+#sudo pacman -S --needed git make gdb zip unzip unrar p7zip wget
89+#sudo pacman -S --needed android-tools jdk11-openjdk
90+
91+# download and extract Android SDK Command Line Tools for Linux
92+# from https://developer.android.com/studio/#downloads
93+mkdir -p "$BASE/android/sdk/cmdline-tools"
94+cd "$BASE/android/sdk/cmdline-tools"
95+wget "https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip"
96+unzip "commandlinetools-linux-9477386_latest.zip"
97+rm "commandlinetools-linux-9477386_latest.zip"
98+mv cmdline-tools tools
99+
100+# Install SDK packages and NDK
101+cd "$BASE/android/sdk/cmdline-tools/tools/bin"
102+yes | ./sdkmanager --licenses
103+# (Note: to view a list of available packages use ./sdkmanager --list)
104+# (a handy reference for API / SDK levels and Android version: https://apilevels.com/)
105+./sdkmanager "platforms;android-31" "build-tools;31.0.0" "tools" "ndk;22.1.7171670" "extras;android;m2repository"
106+# Android sdk for api level 33 also was tested and works
107+#./sdkmanager "platforms;android-33" "build-tools;33.0.2" "tools" "ndk;22.1.7171670" "extras;android;m2repository"
108+
109+# Download FPCUPdeluxe from https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/latest
110+# (tested with version 2.4.0a)
111+mkdir "$BASE/android/fpcupdeluxe_app"
112+cd "$BASE/android/fpcupdeluxe_app"
113+wget "https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/v2.4.0a/fpcupdeluxe-x86_64-linux"
114+chmod +x fpcupdeluxe-x86_64-linux
115+echo "[General]" > fpcupdeluxe.ini
116+echo "InstallDirectory=$BASE/android/fpc-lazarus" >> fpcupdeluxe.ini
117+./fpcupdeluxe-x86_64-linux
118+
119+# Using the FPCUPdeluxe GUI
120+# (The install path is already set to: /home/[your_user]/android/fpc-lazarus)
121+#
122+# 1) At the bottom of the main Window, click the "LAMW" button
123+#
124+# As of 2023-Nov-21, this installs stable FPC (3.2.2), stable Lazarus (v2.2.6), cross
125+# compilers for arm/android and aarch64/android, gradle v6.8.3, and latest LAMW from git.
126+#
127+# 2) (Optional) On module tab click the "OPM" button to install Online Package Manager.
128+# 3) Close FPCUPdeluxe
129+
130+# Change name for the desktop shortcut
131+mv "$(xdg-user-dir DESKTOP)/fpcup-Lazarus_fpc-lazarus.desktop" "$(xdg-user-dir DESKTOP)/Lazarus-LAMW.desktop"
132+sed -i "/^Name=/c\Name=Lazarus-LAMW" "$(xdg-user-dir DESKTOP)/Lazarus-LAMW.desktop"
133+
134+# Create a directory for android projects
135+mkdir -p "$BASE/android/projects"
136+
137+# Edit LAMW settings via the ini file
138+LAMWini="$BASE/android/fpc-lazarus/config_lazarus/LAMW.ini"
139+sed -i "/PathToWorkspace/c\PathToWorkspace=$BASE/android/projects" $LAMWini
140+echo "PathToAndroidSDK=$BASE/android/sdk" >> $LAMWini
141+echo "PathToAndroidNDK=$BASE/android/sdk/ndk/22.1.7171670" >> $LAMWini
142+echo "NDK=6" >> $LAMWini
143+
144+# After launching Lazarus-LAMW, confirm paths and settings are correct
145+# in the Tools | [LAMW] Android Module Wizard | Path Settings menu (CLICK OK)
146+```
147+
148+For new LAMW projects
149+
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)`)`
156+
157+For demo LAMW projects
158+
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`
171+
172+Optional script to create terminal launcher for command line work
173+
174+``` bash
175+#Create shell script and desktop shortcut
176+$BASE = "$HOME" #change this if you installed to a different location above
177+
178+LAMWini="$BASE/android/fpc-lazarus/config_lazarus/LAMW.ini"
179+# Note: the following lines must be copy/pasted as one line, starting at "cat" and ending at "EOF"
180+cat <<EOF > $BASE/android/set_dev_environment
181+#!/bin/sh
182+# Setup environment for fpc / lazarus / android command line work
183+
184+FPC_PATH="$BASE/android/fpc-lazarus/fpc/bin/x86_64-linux"
185+LAZ_PATH="$BASE/android/fpc-lazarus/lazarus"
186+
187+export PPC_CONFIG_PATH=\${FPC_PATH}
188+export PATH=\${FPC_PATH}:\${LAZ_PATH}:\${PATH}
189+
190+export ANDROID_SDK_ROOT="${BASE}/android/sdk"
191+export GRADLE_HOME="$(awk -F '=' '/PathToGradle/{print $NF}' $LAMWini)"
192+export PATH=\${PATH}:\${GRADLE_HOME}/bin
193+
194+cd "$BASE/android/projects"
195+exec /bin/bash
196+EOF
197+chmod +x $BASE/android/set_dev_environment
198+
199+# Note: the following lines must be copy/pasted as one line, starting at "cat" and ending at "EOF"
200+cat <<EOF > "$(xdg-user-dir DESKTOP)/Android-Command-Line.desktop"
201+[Desktop Entry]
202+Type=Application
203+Icon=utilities-terminal
204+Exec=$BASE/android/set_dev_environment
205+Name=Android-Command-Line
206+Terminal=true
207+StartupNotify=false
208+EOF
209+chmod +x "$(xdg-user-dir DESKTOP)/Android-Command-Line.desktop"
210+```
211+
212+Changes
213+
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`
219+
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`
239+
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`
244+
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`
252+
253+---
254+*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