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