Recent

Author Topic: Android phone question.  (Read 5544 times)

Robz

  • New member
  • *
  • Posts: 38
Android phone question.
« on: May 03, 2016, 01:42:30 am »
Hi,
I have no clue where to begin. I want to write an application for my Android phone. I know nothing about smart phones, never had one before; not even a cell phone. Sorry, I do not know the terminology.
Questions:

1. Do I need the Google Android SDK?
2. Can I use Lazarus without the Google Android SDK to write code?
3. Will fpc-3.0.0.i386-win32.cross.android.exe work with the Lazarus IDE?
4. How do I load the binary code from my PC into the Phone ?
a. The phone already has a read write link using  a USB cable. I can read text in the memory areas. The phone provided the driver for the link, seems to be trouble free. However I an not sure that this will work; file system is not NTFS and binary code may not be accessible.
b. Do I need super user (sudo) privileges?

Handoko

  • Hero Member
  • *****
  • Posts: 3053
  • My goal: build my own game engine using Lazarus
Re: Android phone question.
« Reply #1 on: May 03, 2016, 04:29:04 am »
1. Do I need the Google Android SDK?

Yes.

2. Can I use Lazarus without the Google Android SDK to write code?

No. You also need to install Android NDK.

3. Will fpc-3.0.0.i386-win32.cross.android.exe work with the Lazarus IDE?

I don't know what it is. Currently, there are 2 easiest ways to build Android apk using Lazarus: Lazarus Android Module Wizard (LAMW) and laz4android. laz4android only works on Windows system and it has problem with Android 5. LAMW can work on both Windows and Linux.

4. How do I load the binary code from my PC into the Phone ?

Many ways to do it: usb cable, wifi, etc. I prefer usb cable, it is the easiest for me. I copy the apk file to my phone memory and run it using a file manager on my device. I use
Explorer by Speed Software which is free download on Google Play Store.

a. The phone already has a read write link using  a USB cable. I can read text in the memory areas. The phone provided the driver for the link, seems to be trouble free. However I an not sure that this will work; file system is not NTFS and binary code may not be accessible.
b. Do I need super user (sudo) privileges?


Don't think so compilcated. Try it and you will be surprised how easy it is.

Good luck!

jmpessoa

  • Hero Member
  • *****
  • Posts: 1356
Re: Android phone question.
« Reply #2 on: May 03, 2016, 06:40:48 am »

Hello Robz!

Quote

Here is a  rapid "get_start" for windows using:

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

+

LAMW:Lazaru Azandroid Module Wizard"  ref. https://github.com/jmpessoa/lazandroidmodulewizard


I. Infrastructure

.Java  sdk_x86 [32 bits]  ... : http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html.


.Android sdk        -   http://dl.google.com/android/installer_r24.4.1-windows.exe
         after install run "SDK Manager" update your system ...

.Android NDK-r10e   -    http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86.exe

.Ant [to build Anroid Apk]

   http://ant.apache.org/bindownload.cgi
   Simply extract the zip file to a convenient location...

II. LAMW:  Lazarus Android Module Wizard

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

   .Install ordem.

      tfpandroidbridge_pack.lpk
      lazandroidwizardpack.lpk
      amw_ide_tools.lpk     [../ide-tools]

III. USE

1. Configure Paths:

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

2. New Project [thanks to @Developing!]     

   After install "LAMW" packages:

   2.1-From Lazarus IDE select "Project" -> "New Project"

   ref. https://jmpessoa.opendrive.com/files?Ml85OTEwMDQ3OV9BRW45VA

   2.2-From displayed dialog  select "JNI Android Module [Lamw GUI]"    


   2.3-Press OK Button.

   2.4. From form "Android Module wizard: Configure Project..." [Workspace Form]

      ref. https://jmpessoa.opendrive.com/files?Ml85OTEwMDU1Nl9YVE5qUg

   2.4-Fill/complete the field:
      "Path to workspace [project folder]" 
      example c:\LamwProjects

   2.5-Fill/complete the field:
      "New Project Name  [or Selec
      example: MyProject1
      [This is your Android App/Apk name]

   2.6-Select your Sdk [installed] Platform:
      example: Jelly Bean 4.1

   2.7-[MinSdk] Select the  min. Sdk Api to compile your project:
      example: 15

   2.8-[TagetApi] Select the target [api] device
      example: 19

   2.9-Select Instruction:
      example: ARMv6
      
        2.10. If Arm then Select Fpu:
      example: Soft

   2.11-Save All [unit1.pas] in path that is showed ...

3. From "Android Bridge" component tab drag/drop a jTextView in jForm
      set property: PosRelativeToParent  = [rpTop,rpCenterHorizontal]

4. From "Android Bridge" component tab drag/drop a jButton     in jForm
     set property: Anchor = jTextView1
     set property: PosRelativeToAnchor : [raBelow]
     set property:PosRelativeToParent = [rpCenter]
     write code for event property "OnClick"  =  ShowMessage('Hello!')

5.  Lazarus IDE menu "Run" ---> "Buld"   

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"

   .Try change project  "AndroidManifest.xml" according your system installation....

      <uses-sdk android:minSdkVersion="15" android:targetSdkVersion="17"/>

      hint: other target:   "android:targetSdkVersion" !!
      
   .Change your project "build.xml"  according your system installation...

      <property name="target"  value="android-17"/>


9. How to configure a Demo to Use/Test:

      .Lazarus IDE menu Open a [*.lpi] Demo Project   [...\jni]

      .Lazarus IDE menu "Tools" ---> "[Lamw] Android Module Wizard" -->  "Change Project [*.lpi] Ndk Path"

      .set your "NDK" path!

      .change/edit project "build.xml"   according your system..

      <property name="sdk.dir" location="C:\adt32\sdk"/>


10. There are some others docs:   

   "install_tutorial.txt"
         and
   "install_tutorial_eclipse_users.txt"

Thank you!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

tintinux

  • Sr. Member
  • ****
  • Posts: 299
    • Gestinux
Re: Android phone question.
« Reply #3 on: May 03, 2016, 10:10:12 am »
Hi

You can start with this wiki page.  Not all examples (in trunk/demos/Eclipse) are working, but no doubt this will be fixed.

@Handoko : Laz4Android can't be opposed to Lazarus Android Module Wizard. This one is simply an easier way to build, prepare and compile files, and finally call Laz4Android.

Regards
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

Robz

  • New member
  • *
  • Posts: 38
Re: Android phone question.
« Reply #4 on: May 03, 2016, 11:04:42 pm »
Don't think so compilcated. Try it and you will be surprised how easy it is.

Good luck!

 :)

Thank you Handoko for your reply.
Shortly I will get the required prerequisites together. I already installed Google SDK.   
My objective is to transfer my SQLite3 data base application from Windows to Android phone. It makes heavy use the clip board, copy and paste, and onMouse event (finger click?). I know that when I re-compiled the application to Linux, a similar, but different procedure had to be written to access the clip board. I do not know how to access the clipboard in Android. If you have any ideas, your help is much appreciated.
Again, thank you.

Robz

  • New member
  • *
  • Posts: 38
Re: Android phone question.
« Reply #5 on: May 03, 2016, 11:12:52 pm »
Here is a  rapid "get_start" for windows:


Thank jmpessoa for your detailed reply. It is much appreciated. I will review and try your outline. It may take a while; but it should be help full. The comments from all will save me much time getting started.

Thank you
Robert.

Robz

  • New member
  • *
  • Posts: 38
Re: Android phone question.
« Reply #6 on: May 03, 2016, 11:19:22 pm »
Hi

You can start with this wiki page.  Not all examples (in trunk/demos/Eclipse) are working, but no doubt this will be fixed.

Regards

Thank tintinux you for your alternate technique. I'll give it a try.

Robert

Handoko

  • Hero Member
  • *****
  • Posts: 3053
  • My goal: build my own game engine using Lazarus
Re: Android phone question.
« Reply #7 on: May 04, 2016, 03:03:12 am »
Are you a Windows user? What is the Android version of your device? And what is the Android version of your target clients' devices?

Just you has been told, Laz4Android is simply an easier way to build, prepare and compile files to produce Android Apps. You should try Laz4Android first. It's maybe the easiest, you don't even need to download Android SDK and NDK manually. Because it will perform the downloads for you automatically. It's really a nice tool.

Unfortunately, currently Laz4Android only runs on Windows. And the build result Apps has problem when running on Android 5 devices. My only Android device is Android version 5. I had problem to run the apps I build. I'm a Linux user, I have to use VirtualBox to run Laz4Android. I believe it will run on Linux and fix the Android issue in the future. I've been waiting for many months perhaps a year, but the issue still hasn't fixed. So I tried LAMW.

At the beginning, LAMW seems very hard. You have to use DOS/Terminal commands to perform the installation and preparation. While on Laz4Android, such preparation will be handled automatically.

Quote
My objective is to transfer my SQLite3 data base application from Windows to Android phone.

I suggest you to try to build simple "Hello World" first. While both Laz4Android and LAMW still use Pascal language and Lazarus IDE, the way to do things isn't the usual way you already know. For example, normally we just use Form1.Caption := 'New Title'. You won't get the result you expected on LAMW.

Laz4Android uses CustomDrawn widgetset, LAMW uses it's own visual components. They're different, but they can be combined (if I'm not wrong).
« Last Edit: May 04, 2016, 03:10:45 am by Handoko »

jmpessoa

  • Hero Member
  • *****
  • Posts: 1356
Re: Android phone question.
« Reply #8 on: May 04, 2016, 03:14:32 am »
Code: Pascal  [Select]
  1. ...You have to use DOS/Terminal commands to perform the installation and preparation
  2.  

where?  To build/install apk?

if yes, please, connect your device, and try:

Quote
Lazarus IDE menu "Run" ---> "[Lamw] Build Apk and Run"

Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

Handoko

  • Hero Member
  • *****
  • Posts: 3053
  • My goal: build my own game engine using Lazarus
Re: Android phone question.
« Reply #9 on: May 04, 2016, 03:21:17 am »
You misunderstood my saying. Not building the apk. I mean preparing the SDK and NDK links. Something like these (Linux):

Code: Pascal  [Select]
  1. sudo apt-get install android-tools-adb ant fp-compiler openjdk-7-jdk
  2. sudo apt-get install subversion freeglut3 freeglut3-dev
  3. sudo apt-get install libgtk2-gladexml-perl
  4. sudo apt-get install libgtk2.0-bin libgtk2.0-cil libwxgtk2.8-0
  5. mkdir ~/Android
  6. Extract Android NDK https://developer.android.com/ndk/downloads to ~/Android
  7. ln -sf ~/Android/android-ndk-r11c ~/Android/ndk
  8. cd /usr/bin
  9. sudo ln -sf ~/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as arm-linux-androideabi-as
  10. sudo ln -sf ~/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.bfd arm-linux-androideabi-ld
  11. sudo ln -sf /usr/bin/arm-linux-androideabi-as arm-linux-as
  12. sudo ln -sf /usr/bin/arm-linux-androideabi-ld arm-linux-ld
  13. Extract Android SDK https://developer.android.com/sdk to ~/Android
  14. ln -sf ~/Android/android-sdk-linux ~/Android/sdk
  15. Install SDK Packages by running ~/Android/sdk/tools/android
  16. Add to ~/.bashrc: export PATH=$PATH:~/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin

The code above are the things I have to do perform re installation (or a clean installation) of LAMW. It's will be too hard for users who don't have DOS/Terminal knowledge.

Handoko

  • Hero Member
  • *****
  • Posts: 3053
  • My goal: build my own game engine using Lazarus
Re: Android phone question.
« Reply #10 on: May 04, 2016, 03:27:55 am »
Suggestion to improve "new_how_to_install_by_renabor.txt" installation instruction.

It uses:
sudo ln -s .....

It's ok, but it will be better to include "f" option to force the link creation (if the link already exist):
sudo ln -sf .....

jmpessoa

  • Hero Member
  • *****
  • Posts: 1356
Re: Android phone question.
« Reply #11 on: May 04, 2016, 03:29:57 am »

Linux?

Yes, you're right!

An alternative [for beginner] is to start learning LAMW on windows using Laz4Android...

Please, send me your improved "new_how_to_install_by_renabor.txt", I will post it in github!

Thank You!
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard