You are on page 1of 5

[Getting Started.

txt]

LAMW: Lazarus Android Module Wizard

RAD Android!

"Getting Started" for Windows [by Jose Marques Pessoa]

About Linux: LAMW folder "...docs\linux"

.Github
ref. https://github.com/jmpessoa/lazandroidmodulewizard

.Forum
ref. http://forum.lazarus.freepascal.org/index.php/topic,21919.0.html

I. Infrastructure

.Java JDK [32 bits or 64 bits]

.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

.Android SDK [updated] --- 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-ndroid compiler installed!]


http://sourceforge.net/projects/laz4android/files/?source=navbar

:: OR Lazarus [canonical]
Do It Yourself 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.1 [to build Apk with "AppCompat" [material] theme]

https://gradle.org/next-steps/?version=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] theme need:'+


1. Java JDK 1.8'
2. Gradle 4.1 [https://gradle.org/next-steps/?version=4.1&format=bin]
3. Android SDK "plataforms" 25 + "build-tools" 25.0.3 [or]
3. Android SDK "plataforms" 26 + "build-tools" 26.0.3 [or]
3. Android SDK "plataforms" 27 + "build-tools" 27.0.3
4. Android SDK/Extra "Support Repository"
5. Android SDK/Extra "Support Library"

II. LAMW: Lazarus Android Module Wizard

.Install order.

tfpandroidbridge_pack.lpk [..../android_bridges]
lazandroidwizardpack.lpk [..../android_wizard]
amw_ide_tools.lpk [..../ide_tools]

III. USE

1. Configure Paths:

Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" --> "Path
Settings ..."

ref. https://od.lk/f/Ml8xNTU4Mjc1NDZf

2. 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: [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".

You might also like