Saturday, November 24, 2018

  • LAMW: Lazarus Android Module Wizard

    LAMW: Lazarus Android Module Wizard

    RAD Android! "Getting Started" for Windows [by Jose Marques Pessoa] Linux Install Tutorial: LAMW folder "...docs\linux" About MacOS: X11 [libGL.dylib] is no longer bundled with Mountain Lion (and later!) [This prevents/drop some LAMW features, including the use of OpenGL components "jCanvasES1" and "jCanvasES2"] About MacOs Install: [adapted from ".../docs/linux/tutorial_by_waynesherman] .Install [I] Infrastructure .Install FPCUpdeluxe https://github.com/newpascal/fpcupdeluxe/releases/download/v1.6.0q/fpcupdeluxe-powerpc-darwin-carbon.app.zip .Use FPCUpdeluxe to Install FPC+Laz [trunk or stable or ...] .Use FPCUpdeluxe to Install arm/android cross-compile .Github ref. https://github.com/jmpessoa/lazandroidmodulewizard .Forum ref. http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html I. Infrastructure .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] --- "ant" and "gradle" build supported... [recommended!!!] [Windows] http://dl.google.com/android/installer_r24.0.2-windows.exe [Linux] http://dl.google.com/android/android-sdk_r24.0.2-linux.tgz [Mac] http://dl.google.com/android/android-sdk_r24.0.2-macosx.zip Hint: 1)after unpacked/install, open a command line Terminal and go to folder "sdk/tools" 2)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 25.0.3" 6)check "Android SDK Build-Tools 26.0.2" 7)go to "Android 7.1.1 (API 25)" and check only "SDK Platform" 8)go to "Android 8.0.0 (API 26)" and check only "SDK Platform" 9)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] --- only "gradle" build 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 .Laz4Android [Windows] [cross-arm-android compiler installed!] http://sourceforge.net/projects/laz4android/files/?source=navbar :: OR Lazarus [canonical] "Do It Yourself" a cross Android compile! [windows]: After install the LAMW go to: 1. IDE "Tools" --> "[Lamw] Android Module Wizard" --> "Get FPC Source [Trunk]" 2. IDE "Tools" --> "[Lamw] Android Module Wizard" --> "Build FPC Cross Android" .Ant [to build Apk] http://ant.apache.org/bindownload.cgi Simply extract the zip file to a convenient location... .Gradle 4.4.1 [to build Apk with "AppCompat" [material design] theme] https://gradle.org/next-steps/?version=4.4.1&format=bin Simply extract the zip file to a convenient location... warning: Gradle build process need internet connection!!! .Hint [Lazarus Docked Desktop. Nice!] https://github.com/FlKo/LazarusDockedDesktops .[LAMW 0.8] "AppCompat" [material design] theme need:'+ 1. Java JDK 1.8 2. Gradle 4.4.1 [https://gradle.org/next-steps/?version=4.4.1&format=bin] 3. Android SDK "plataforms" 26 + "build-tools" 26.0.2 4. Android SDK/Extra "Support Repository" 5. Android SDK/Extra "Support Library" 5. Android SDK/Extra "Google Repository" 5. Android SDK/Extra "Google Play Services" II. LAMW: Lazarus Android Module Wizard .Install order. tfpandroidbridge_pack.lpk [..../android_bridges] lazandroidwizardpack.lpk [..../android_wizard] amw_ide_tools.lpk [..../ide_tools] III. USING LAMW 1. Configure Paths: Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" --> "Path Settings ..." ref. https://od.lk/f/Ml8xNTU4Mjc1NDZf 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 [projects folder]" example: C:\MyLamwProjects 2.5-Fill/complete the field: "New Project Name [or Selec one] example: LamwGUIProject1 [This is your Android App/Apk name] 2.6-[MinSdk] Select the Min. Device Api need to run your App: example: 14 2.8-Select Architecture/Instruction: example: ARMv6 2.9.Select Android Theme example: [DefaultDevice] or "AppCompat" for material design theme 2.9.Click "OK" 2.10-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 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 <device name>" 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.PANIC? Fail to buid "Apk" or Run "Demos"... .Try change project "AndroidManifest.xml" according your Android SDK system installation.... .<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17"/> .Change your project "build.xml" according your Android SDK system installation and "AndroidManifest.xml" .<property name="target" value="android-17"/> 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. NOTE: All LAMW projects [and demos] are Eclipse compatible! Thank you! 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".
  • 0 comments:

    Post a Comment

    Copyright @ Solve It Your Way: LAMW: Lazarus Android Module Wizard

    I Love My Family