[Getting Started.txt] LAMW: Lazarus Android Module Wizard RAD Android! "Getting Started" .Github ref. https://github.com/jmpessoa/lazandroidmodulewizard .Forum ref. http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html I - Lazarus for Android .Option 1) Laz4Android [Windows] [cross-android compiler already installed!] http://sourceforge.net/projects/laz4android/files/?source=navbar Hint: Install here: "C:\laz4android2.0.12" [not "Program Files" !!!] NEW! laz4android2.0.12 "out of box" now support: win32/win64/arm-android/aarch64-android/i386-android/x86_64-android/jvm-android cross-compile! LAMW Install .ref. https://github.com/jmpessoa/lazandroidmodulewizard/archive/master.zip after download unzip it in some folder [recommended folder "C:\laz4android2.0.12\components"]! .packages Installations order tfpandroidbridge_pack.lpk [..../android_bridges] lazandroidwizardpack.lpk [..../android_wizard] amw_ide_tools.lpk [..../ide_tools] .Option 2) "LAMW Manager" https://forum.lazarus.freepascal.org/index.php/topic,45361.0.html ["All in One"] https://github.com/DanielOliveiraSouza/LAMW4Linux-installer https://github.com/DanielOliveiraSouza/LAMW4Windows-installer .Option 3) Fpcupdeluxe [Linux and windows] https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases .Option 4) "Do It Yourself": Lazarus + FPC 3.2.0 [canonical/windows] 4.1 LAMW Install .ref. https://github.com/jmpessoa/lazandroidmodulewizard/archive/master.zip after download unzip it in some folder [recommended folder "C:\laz4android2.0.12\components"]! .packages Installations order tfpandroidbridge_pack.lpk [..../android_bridges] lazandroidwizardpack.lpk [..../android_wizard] amw_ide_tools.lpk [..../ide_tools] 4.2. Get the FPC source [trunk] from: https://gitlab.com/freepascal.org/fpc/source/-/archive/main/source-main.zip ' Unzip it in some folder and point up the path in step "4.3" 4.3. IDE "Tools" --> "[LAMW] Android Module Wizard" --> "Build FPC Cross Android" [ex. Armv7a + Soft] 32bits <<---- tested! .Build .Install [ex. aarch64] 64bits <<---- tested! .Build .Install If need, [after Build and install] repeat the "Build and install" process once for each architecture! Hint: After "build" and "install" the cross-compilers and all "II. Infrastructure" go to "III. USING LAMW" and try to create your first [New] LAMW project! If you get a error "Fatal: Cannot find unit system used by fcllaz of package FCL." when trying "Run" --> "Build" your project try fix the "fpc.cfg" file: 4.3.1) Go to "fpc.cfg" [ex. "lazarus\fpc\3.2.0\bin"] Change: # searchpath for units and other system dependent things -FuC:\lazarus1864\fpc\$FPCVERSION/units/$fpctarget -FuC:\lazarus1864\fpc\$FPCVERSION/units/$fpctarget/* -FuC:\lazarus1864\fpc\$FPCVERSION/units/$fpctarget/rtl To: # searchpath for units and other system dependent things -FuC:\lazarus1864\fpc\3.2.0/units/$fpctarget -FuC:\lazarus1864\fpc\3.2.0/units/$fpctarget/* -FuC:\lazarus1864\fpc\3.2.0/units/$fpctarget/rtl 4.3.2) Go to Lazarus IDE menu "Tools" --> "Options" --> "Environment" [FPC Source] Change: $(LazarusDir)fpc\$(FPCVer)\source To: $(LazarusDir)fpc\3.2.0\source II. Infrastructure :: only for non-users of "LAMW Manager" !! .Java JDK 8 : [recommended!!!] http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html Warning: Java JDK > 8 don't support [anymore] "ant" build system! .Android SDK [old/recommended!] --- "ant" and "gradle" builder systen supported... [recommended!!!] [Windows] https://dl.google.com/android/repository/tools_r25.2.5-windows.zip [Linux] https://dl.google.com/android/repository/tools_r25.2.5-linux.zip [Mac] https://dl.google.com/android/repository/tools_r25.2.5-macosx.zip Hint: 0)unpacked/install to a "sdk" folder 1)after unpacked/install, open a command line Terminal and go to folder "sdk/tools" 2)go to cmd console and run the command >> "android update sdk" to open a GUI "SDK Manager" 3)check "Android SDK Tools" 4)check "Android SDK Platform-Tools" 5)check "Android SDK Build-Tools 29.0.3" [and others updated version] 6)check "Android SDK Build-Tools 28.0.3" [and others updated version] 8)go to "Android 10 (API 29)" and check only "SDK Platform" [and others updated version] 9)go to "Android 9 (API 28)" and check only "SDK Platform" [and others updated version] 10)go to "Extras" and check: "Android Support Repository" "Android Support Library" "Google USB Drive" //windows only... "Google Repository" "Google Play Services" .Android SDK [updated/modern version] --- warning: Only "gradle" builder supported... [Windows] https://dl.google.com/android/repository/sdk-tools-windows-3859397.zip [Linux] https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip [Mac] https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip .Android NDK https://developer.android.com/ndk/downloads/index.html .Ant [to build Apk] http://ant.apache.org/bindownload.cgi Simply extract the zip file to a convenient location... .Gradle 6.6.1 ["must have" to build Apk with AndroidX AppCompat/Material theme!] https://gradle.org/releases/ https://gradle.org/next-steps/?version=6.6.1&format=bin Simply "extract here" the zip file to produce the folder "gradle-6.6.1" in a convenient location... Warning: Gradle >= 7 don't supported by LAMW, yet! warning: Gradle build process need internet connection!!! Warning: Gradle 6.X don't support Java > 13! III. USING LAMW 1. Configure Paths: Lazarus IDE menu "Tools" ---> "[LAMW] Android Module Wizard" --> "Paths Settings ..." NOTE: [MacOs >= 10.5] path to Java JDK auto setting as: ${/usr/libexec/java_home} 2. [How to] New Project [Thanks to Ahmad Bohloolbandi (a.k.a. @developing)] After install "LAMW" packages and Configured the paths: 2.1. From Lazarus IDE select "Project" -> "New Project" ref. https://od.lk/f/Ml8xNTU4Mjc1NThf 2.2. From displayed dialog select "[LAMW] GUI Android Module" 2.3. Press OK Button. 2.4. From Form "Android Module wizard: Configure Project..." [Workspace Form] ref. https://od.lk/f/Ml8xNTU4Mjc1NjBf 2.4. Fill/complete the fields: "Path to workspace [your projects folder]" example: C:\MyLamwProjects 2.5. Fill/complete the field: "New Project Name [or Selec one] example: AppLAMWProject1 [This is your Android App/Apk name] 2.6. [MinNkd] Select the Min. NDK api: example: 22 [warning: ndkApi > 22 will not run on old Android 4.x devices] 2.7. [MinSdk] Select the Min. Device Api need to run your App: example: 14 warning: some LAMW component can change/need a more recent MinSdk Api 2.8. Select Architecture/Instruction: example: ARMv7a + Soft NOTE: .laz4android2.0.12 support "ARMv7a + Soft" and "Aarch64" and others! .Fpcupdeluxe support "ARMv7a + VFPv3" and "Aarch64" and others! .LAMW Manager support "ARMv7a + VFPv3" and "Aarch64" 2.9. Select Android Theme example: [DefaultDevice] or "AppCompat" for "material design" theme 2.10. Click "OK" 2.11. Save All [unit1.pas] to path that is showed ... 3. From "Android Bridge" component tab drag/drop a jTextView in the "Android Module Form" designer set property: PosRelativeToParent = [rpTop,rpCenterHorizontal] WARNING! .Please, whenever a dialog prompt, select "Reload from disk" 4. From "Android Bridge" component tab drag/drop a jButton the "Android Module Form" designer set property: Anchor = jTextView1 set property: PosRelativeToAnchor : [raBelow] set property: PosRelativeToParent = [rpCenter] write code for event property "OnClick": example: ShowMessage('Hello!') 5. Lazarus IDE menu "Run" ---> "Build" PANIC? Please, go to: III.1. "Configure Paths" and try fix its! 6. Connect your Device to Computer [usb] and configure it to "debug mode" "App settings" ---> more/aditional -- developer options [*]: stay awake [checked!] usb debugging [checked!] verify apps via usb [checked!] PANIC? Go to Google search with "android usb debugging " to get the operating mode adapted to your device... ex. Galaxy S3/S4 --> app settings --> about -->> Build number -->> [tap,tap,tap,...] ex. MI 2 --> app settings --> about -->> MIUI Version -->> [tap,tap,tap,...] 7.Lazarus IDE menu "Run" ---> "[Lamw] Build Apk and Run" [Congratulations!!!] 8) How to get more/others ".so" chipset builds: IMPORTANT! Google Play NOW require APKs to include both 32 and 64 bits version of LAMW "*.so" libraries.... .warning: Your Lazarus/Freepascal needs to be prepared [cross-compile] for the various chipset builds! 8.1. From LazarusIDE menu: > Project -> Project Options -> Project Options -> [LAMW] Android Project Options -> "Build" -> Chipset [select!] -> [OK] 8.2. From LazarusIDE menu: > Run -> Clean up and Build... 8.3. From LazarusIDE menu: > [LAMW] Build Android Apk and Run NOTE: If desirable/wanted repeat 8.1/8.2/8.3 for other CPUs... 9. Using/Testing "Demos": [Please, before try a demo, do yourself a first "hello world" apk!] [so, you can test your environment settings ...] .Lazarus IDE menu --> Open the project *.lpi [....\jni] .Lazarus IDE menu --> Project --> Project Inspector --> "Unit1.pas" [etc...] .Lazarus IDE menu "Run" ---> "Build" .Lazarus IDE menu "Run" ---> "[Lamw] Build Apk and Run" [Congratulations!!!] 10. NOTE1: All LAMW projects [and demos] are Android Studio compatibles! ref. https://github.com/jmpessoa/lazandroidmodulewizard/blob/master/docs/How_to_open_LAMW_project_with_AndroidStudio.txt NOTE2: Components from Palettes/Tabs "Android Bridges AppCompat" and "Android Bridges JCenter" need build system "Gradle" [and Internet connection] 11. About "untitled" demos: AppTest1 : multi-form demo AppTest2: jni coding "the hard way" AppTryCode1: jHello component demo [array, strings, etc...] AppTryCode2: jMediaPlayer1 and jSurfaceView1 components demo AppTryCode2: jDumpJavaMethods component demo [about java to pascal converter...] Thanks to All! [FAQ 2]: [Thanks to Ahmad Bohloolbandi (a.k.a. @developing) ] #Question: How do we can design a layout that shown same in real device? [Answer]: You should use the component properties: "Anchor", "PosRelativeToParent", "PosRelativeToAnchor", "LayoutParamHeight", "LayoutParamWhidth" Example: 1-Put a "jTextView" component on your AndroidModule form: Set "PosRelativeToParent" "rpCenterHorizontal" [True] "rpTop" [True] 2-Put a "jButton" component on AndroidModule form: Set "Anchor" to "jTextView" (Because you should set position relative with "jTextView") set "PosRelativeToAnchor" "raBelow" [True] 3-Put a "jEditText" component on form: Set "Anchor" to "jButton". Set "PosRelativeToAnchor" "raBelow" [True] NOTE: Anchor setting is most important section of this design, because your component position depends on this property. And for change width and/or height of each components you should change/configure "LayoutParamWhidth" and/or "LayoutParamHeight".