Italian community of Lazarus and Free Pascal
Programmazione => Mobile => Topic aperto da: xinyiman - Agosto 27, 2015, 01:30:17 pm
-
Questa è la guida aggiornata suggeritami da un utente che programma regolarmente con android/lazarus da linux. Nei prossimi giorni la testo su una macchina virtuale. Se funziona bene vi giro la macchina virtuale.
I've updated the guide, integrating it with more specific steps.
A note on fpc version, that must be 2.6.4 for compiling the trunk version (3.1.1).
If you have Ubuntu 14.04 (like me) you must download the correct version from here:
http://packages.ubuntu.com/vivid/fpc-2.6.4
Thank you!
#######################
(replace $HOME with your username)
################
install some necessary programs:
(CMD) sudo apt-get install android-tools-adb ant fp-compiler openjdk-7-jdk subversion
################
(CMD) mkdir ~/Android
(CMD) cd ~/Android
################
install Android NDK
################
Download Android NDK from https://developer.android.com/ndk/downloads/index.html#download
follow instruction to install it
create a symbolik link for later use
(CMD) ln -s /home/$HOME/Android/android-ndk-r10e /home/$HOME/Android/ndk
################
install Android Sdk
################
Download Android Sdk from https://developer.android.com/sdk/index.html#Other (SDK Tools Only)
and extract it
(CMD) tar xzvf android-sdk_r24.3.4-linux.tgz
create a symbolik link for later use
(CMD) ln -s /home/$HOME/Android/android-sdk-linux /home/$HOME/Android/sdk
################
install SDK packages
################
Follow these instructions
https://developer.android.com/sdk/installing/adding-packages.html
and install SDK packages
(CMD) ~/Android/sdk/tools/android sdk
################
modify your PATH
################
Add to your ~/.bashrc:
export PATH=$PATH:~/Android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin
################
download FPC and LAZARUS
################
svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus
svn co http://svn.freepascal.org/svn/fpc/trunk fpc
################
install other needed packages
################
(ref.: http://wiki.freepascal.org/How_to_setup_a_FPC_and_Lazarus_Ubuntu_repository)
sudo apt-get install libgtk2.0-dev libgdk-pixbuf2.0-dev libgpm-dev fakeroot libncurses5-dev libtinfo-dev
################
BUILD FPC.DEB
################
(CMD) cd ~/Android/lazarus/tools/install
(CMD) ./create_fpc_deb.sh fpc /home/$HOME/Android/fpc/
################
purge fpc from system
################
REMOVE all fpc deb and fp_ deb (fpc, fpc-src, fp_compiler and so on)
(EX) sudo dpkg --remove fpc* fp-*
################
INSTALL the new trunk fpc package
################
(CMD) sudo dpkg -i ./fpc_3.1.1-150130_amd64.deb
################
BUILD FPC-SRC.DEB
we need source for fpc, now we create it, and install it
################
(CMD) ./create_fpc_deb.sh fpc-src /home/$HOME/Android/fpc/
(CMD) sudo dpkg -i fpc-src_3.1.1-150130_amd64.deb
################
BUILD LAZARUS.DEB AND INSTALL IT
################
(CMD) ./create_lazarus_deb.sh append-revision
(CMD) sudo dpkg -i lazarus_1.5.47565-0_amd64.deb
################
BUILD THE CROSS COMPILER
################
make clean crossall OS_TARGET=android CPU_TARGET=arm
sudo make crossinstall OS_TARGET=android CPU_TARGET=arm INSTALL_PREFIX=/usr
################
create symbolic link for newly created arm compiler
################
(CMD) cd /usr/bin
(CMD) sudo ln -s /usr/lib/fpc/3.1.1/ppcrossarm .
(CMD) sudo ln -s /usr/bin/ppcrossarm ppcarm
################
create symbolic link for linker
################
(CMD) sudo ln -s ~/Android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-as
(CMD) sudo ln -s ~/Android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ld.bfd
(CMD) ln -s /usr/bin/arm-linux-androideabi-as arm-linux-as
(CMD) ln -s /usr/bin/arm-linux-androideabi-ld arm-linux-ld
################
update /etc/fpc.cfg
################
Add these lines to /etc/fpc.cfg
#IFDEF ANDROID
#IFDEF CPUARM
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
#ENDIF
#ENDIF
################
install LAMW
################
(CMD) svn co https://github.com/jmpessoa/lazandroidmodulewizard.git
(CMD) ln -s /home/$HOME/Android/svn-lazandroidmodulewizard/trunk /home/$HOME/Android/lazandroidmodulewizard
################
Install LAMW on Lazarus
################
1. From Lazarus IDE - Install Wizard Packages
1.1 Package -> Open Package -> "tfpandroidbridge_pack.lpk" [Android Components Bridges!]
1.1.1 From Package Wizard
- Compile
- Use -> Install
1.2 Package -> Open Package -> "lazandroidwizardpack.lpk"
1.2.1 From Package Wizard
- Compile
- Use -> Install
1.3 Package -> Open Package -> "amw_ide_tools.lpk" [folder: ..\LazAndroidWizard\ide_tools]
1.3.1 From Package Wizard
- Compile
- Use -> Install
2. From Lazarus IDE menu Tools -->> "Android Module Wizard" --> Paths Settings"
update paths settings according to your system
(ref. https://jmpessoa.opendrive.com/files?Ml82Nzg4MzA1OF9yVVU3RA)
-Path to Java JDK (ex. /usr/lib/jvm/java-7-openjdk-amd64)
-Path to Android SDK( ex. /home/renabor/Android/sdk)
-Path to Ant bin (ex. /usr/bin)
-Select Ndk version: [10]
-Path to Ndk (ex /home/$HOME/Android/android-ndk-r10e)
-Path to Java Resources [Simonsayz's Controls.java, *.xml and default Icons]: (ex. /home/$HOME/Android/svn-lazandroidmodulewizard/trunk/java)
################
BUILD YOUR FIRST PROJECT
################
Open a project from lazandroidmodulewizard/demos/Ant or lazandroidmodulewizard/demos/Eclipse directory
open ~/Android/lazandroidmodulewizard/demos/Eclipse/AppDemo1/jni/controls.lpi
from Project->Options, change/modify paths according to your system (under «paths» and «other»)
(ex. for «paths» ../../../Android/android-ndk-r10e/platforms/android-21/arch-arm/usr/lib;/home/$HOME/Android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.6/)
(ex. for «other» -Xd -CfSoft -CpARMV6 -XParm-linux-androideabi- -FD/home/$HOME/Android/android-ndk-r10e/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin)
build it!
################
################
compile for ARM
################
################
from shell
(CMD) cd ~/Android/lazandroidmodulewizard/demos/Eclipse/AppDemo1
################
build.xml
################
<?xml version="1.0" encoding="UTF-8"?>
<project name="AppDemo1" default="help">
<property name="sdk.dir" location="/home/$HOME/Android/sdk"/>
<property name="target" value="android-19"/>
<property file="ant.properties"/>
<fail message="sdk.dir is missing." unless="sdk.dir"/>
<import file="${sdk.dir}/tools/ant/build.xml"/>
</project>
################
build.sh
################
edit build.sh and leave only this line:
ant -Dtouchtest.enabled=true debug
################
install.sh
################
- FROM COMMAND LINE
chmod +x ./build.sh
./build.sh
cd bin
~/Android/sdk/tools/android avd &
adb install AppDemo1-debug.apk
Enjoy!
-
Ottimo, grazie !!!!
Ciao, Mario