Difference between revisions of "Android tutorial"

From Free Pascal wiki
Jump to navigationJump to search
m
 
(12 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
{{Android tutorial}}
 +
{{Platform only|Android|Android|Android}}
 
=Windows=
 
=Windows=
  
Bu Lazarus ile Android uygulamanın nasıl geliştirleceğini anlatan bir hızlı öğreticidir.
+
This is a quick tutorial on how to create android apps with Lazarus.
Bu eğitimde JDK 1.6u45 + SDK 22.2.1 + ndk-r9 + Laz4Android1.1-41139-FPC2.7.1 paketleri üzerinden anlatım yapılmıştır.
 
  
==Dizin Hazırlanması==
+
In this tutorial assume used versions JDK 1.6u45 + SDK 22.2.1 + ndk-r9 + Laz4Android1.1-41139-FPC2.7.1
Sürücü C üzerinde “Android” isimli bir dizin oluşturun.
 
  
==JDK Yükleme==
+
==Prepare folder==
1.6u45 (Bende jdk-6u45-windows-x64.exe yüklü vaziyette)
+
Create on C:\ a folder called "Android"
  
 +
==Install JDK==
 +
1.6u45 (i have installed jdk-6u45-windows-x64.exe)
 +
arm-linux-androideabi/bin
 
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR
 
http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR
  
Bu bağlantıdaki paket C:\Program Files\Java\. İçine yüklenmiş olmalı.
+
It will be installed in to C:\Program Files\Java\.
  
==SDK yı Kurmak==
+
==Install SDK==
http://developer.android.com/sdk/index.html adresine git.
+
Go to http://developer.android.com/sdk/index.html
  
DİĞER PLATFORMLAR İÇİN OLAN > SDK ARAÇLARINI İNDİR.
+
DOWNLOAD FOR OTHER PLATFORMS > SDK Tools Only
installer_r22.2.1-windows.exe (Önerilir)
 
sdk (installer_r22.2.1-windows) yı C:\Android\android-sdk içine kur.
 
"apkbuilder.bat" dosyasını  "C:\Android\android-sdk\tools"  içine kopyala (burada bulabilirsiniz 
 
https://raw.github.com/ACSOP/android_sdk/master/apkbuilder/etc/apkbuilder.bat)
 
  
Şimdi SDK'yı güncelle  [WIN BAŞLAT > SDK Manager ]
+
installer_r22.2.1-windows.exe (Recommended)
android 4.0 (API 14)' ü ekle
 
android 2.2 (API 8) 'i ekle
 
paketleri kur
 
  
==NDK'yı Kurmak==
+
Install sdk (installer_r22.2.1-windows) into C:\Android\android-sdk
 +
 
 +
Copy at "C:\Android\android-sdk\tools" the file "apkbuilder.bat" (can be found here
 +
 
 +
https://github.com/ACSOP/android_sdk/raw/master/apkbuilder/etc/apkbuilder.bat )
 +
 
 +
Now update the SDK [WIN START > SDK Manager ]
 +
 
 +
add android 4.0 (API 14)
 +
 
 +
add android 2.2 (API 8]
 +
 
 +
Install packages.
 +
 
 +
==Install NDK==
 
http://developer.android.com/tools/sdk/ndk/index.html
 
http://developer.android.com/tools/sdk/ndk/index.html
  
sadece android-ndk-r9-windows-x86.zip dosyasını indirin
+
Download only the file android-ndk-r9-windows-x86.zip
android-ndk-r9-windows-x86.zip zip dosyasını C:\Android\android-ndk-r9 içine ayıklayın.
+
 
 +
Unzip android-ndk-r9-windows-x86.zip into C:\Android\android-ndk-r9
 +
 
  
 +
==Install Laz4Android==
 +
Download it from https://skydrive.live.com/?cid=89ae6b50650182c6&id=89AE6B50650182C6!149
  
==Laz4Android 1.1-41139-FPC2.7.1.7z nın Kurulması==
+
New version can download from here:[http://sourceforge.net/projects/laz4android/]
https://skydrive.live.com/?cid=89ae6b50650182c6&id=89AE6B50650182C6!149 adresinden indir.
 
  
Laz4Android1.1-41139-FPC2.7.1.7z dosyasını “C:\Android\laz4android” içine aç
+
Unzip Laz4Android1.1-41139-FPC2.7.1.7z into C:\Android\laz4android
  
Şu kopyalamayı yap
+
Copy
  
 
C:\Android\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-*.exe
 
C:\Android\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-*.exe
adresinden
+
 
 +
to
 +
 
 
C:\Android\laz4android\fpc\2.7.1\bin\i386-win32\*
 
C:\Android\laz4android\fpc\2.7.1\bin\i386-win32\*
adresine.
 
  
"C:\Android\laz4android\build.bat" dosyasını şu şekilde düzenleyin :
+
Edit the file C:\Android\laz4android\build.bat like this :
  
 
<syntaxhighlight lang="dos">
 
<syntaxhighlight lang="dos">
Line 53: Line 67:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Built.bat dosyasını(çift tıklayarak) çalıştırın. Bu Lazarus' a derlemeyi ve inşaa etmeyi yapacaktır.
+
Run build.bat (doubleclick) ->  It will compile & build lazarus.
 +
 
 +
==Rebuild Laz4Android IDE==
 +
Run C:\Android\laz4android\lazarus.exe
 +
 
 +
Select "Start IDE"
 +
 
 +
select "Package" "Install/Uninstall Packages"
 +
 
 +
select customdrawn 0.0 > install selection and hit save and rebuild IDE , continue
 +
 
 +
 
 +
==Compile the demo "androidlcl"==
 +
Copy C:\Android\laz4android\examples\androidlcl at C:\Android\Projects\androidlcl
 +
 
 +
Run "C:\Android\laz4android\lazarus.exe"
  
 +
File > open "C:\Android\Projects\androidlcl\androidlcltest.lpr"
  
==Laz4Android Paketinin IDE ye İnşaa Edilmesi==
+
Project > project options
C:\Android\laz4android\lazarus.exe dosyasını çalıştır.
 
"Start IDE" yi seç.
 
"Package" "Install/Uninstall Packages" 'i seç.
 
Customdrawn 0.0' ı seçin. Devamında seçili olanı yüklediğinizda IDE yi yeniden inşaa(rebuild) edin.
 
  
 +
Compiler options >  select "Release TAndroid"
  
=="androidlcl" Demosunun Derlenmesi==
+
Paths >  
C:\Android\Projects\androidlcl” ye “C:\Android\laz4android\examples\androidlcl” yi kopyala.
 
"C:\Android\laz4android\lazarus.exe" yi çalıştır.
 
Menüden Dosya > Aç "C:\Android\Projects\androidlcl\androidlcltest.lpr"
 
  
Proje > proje Seçenekleri
+
Libraries -Ll :
Derleme Seçenekleri > Seç "Release TAndroid"
+
C:\Android\android-ndk-r9\platforms\android-8\arch-arm\usr\lib;C:\Android\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.6
Yollar >
 
Kütüphaneler -Ll : C:\Android\android-ndk-r9\platforms\android-8\arch-arm\usr\lib;C:\Android\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.6
 
Hedef Dosya Adı : android\libs\armeabi\liblclapp.so
 
  
 +
Target file name :
 +
android\libs\armeabi\liblclapp.so
  
Kod Oluşturma:
+
Code generation
 
   Target OS -T android
 
   Target OS -T android
 
   Target CPU -P arm
 
   Target CPU -P arm
 
   Target processor default
 
   Target processor default
  
Bağlayıcı (Linking):
+
Linking :
 
   Enable strip symbols (-Xs)
 
   Enable strip symbols (-Xs)
  
Diğer : -dANDROID -Xd -CpARMV6 -FLlibdl.so
+
Other : -dANDROID -Xd -CpARMV6 -FLlibdl.so
  
Ide makro değerleri:
+
Ide macro values :
makro adı: LCLWidgetTip
+
macro name : LCLWidgetType
makro değeri : customdrawn
+
macro value : customdrawn
  
Şimdi Çalıştır > Derlemek bu kütüphaneyi üretecek  : C:\Android\Projects\androidlcl\android\libs\armeabi\liblclapp.so [5.073 kb]
+
Now
 +
Run > Compile this will generate this library :
 +
C:\Android\Projects\androidlcl\android\libs\armeabi\liblclapp.so [5.073 kb]
  
  
==Dağıtımın Yapılması==
+
==Deployment==
  
* C:\Android\Projects\androidlcl\android\generate_debug_key.bat dosyasını Yazı editöründe düzenlemek için aç.
+
* Edit with a text editor
 +
C:\Android\Projects\androidlcl\android\generate_debug_key.bat
  
Bu şekilde ilk 6 satırı değiştirin :
+
Modify the first 6 lines like this :
  
 
<syntaxhighlight lang="dos">
 
<syntaxhighlight lang="dos">
REM Senin için bu yolları ayarlayalım
+
REM Adjust these paths to yours
 
SET PATH=C:\Android\android-sdk\tools;C:\Android\android-sdk\build-tools\17.0.0;C:\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_45\bin
 
SET PATH=C:\Android\android-sdk\tools;C:\Android\android-sdk\build-tools\17.0.0;C:\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_45\bin
 
SET APP_NAME=lcltest
 
SET APP_NAME=lcltest
Line 107: Line 133:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
"generate_debug_key.bat" dosyasını çalıştır.
+
Run "generate_debug_key.bat"
Parola bunu kullan : "senhas"
+
 
Bu dosyayı üretecek :
+
Use as password : "senhas"
 +
 
 +
This will produce the file :
 +
 
 
C:\Android\Projects\androidlcl\android\bin\LCLDebugKey.keystore
 
C:\Android\Projects\androidlcl\android\bin\LCLDebugKey.keystore
  
* “C:\Android\Projects\androidlcl\android\build_debug_apk.bat” dosyasını Yazı editöründe düzenlemek için aç.
 
  
Bu şekilde ilk 6 satırı değiştirin :
+
* Edit with a text editor
 +
C:\Android\Projects\androidlcl\android\build_debug_apk.bat
  
 +
Modify the first 6 lines like this :
 
<syntaxhighlight lang="dos">
 
<syntaxhighlight lang="dos">
REM Senin için bu yolları ayarlayalım
+
REM Adjust these paths to yours
 
SET PATH=C:\Android\android-sdk\tools;C:\Android\android-sdk\build-tools\17.0.0;C:\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_45\bin
 
SET PATH=C:\Android\android-sdk\tools;C:\Android\android-sdk\build-tools\17.0.0;C:\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_45\bin
 
SET APP_NAME=lcltest
 
SET APP_NAME=lcltest
Line 125: Line 155:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
"build_debug_apk.bat" dosyasını çalıştırdığında sorulara cevap olarak istenildiğinde parola “senhas” cevabını ver.
 
  
Bu dosya üretilecek.
+
I had to change mine to this on sdk version 22:
 +
<syntaxhighlight lang="dos">
 +
SET APK_BUILD_TOOLS=C:\development\android-sdk\build-tools\22.0.1
 +
SET PATH=C:\development\android-sdk\tools;C:\development\android-sdk\platform-tools\;C:\Program Files\Java\jdk1.7.0_79\bin;%APK_BUILD_TOOLS%
 +
SET APP_NAME=androidlcl
 +
SET ANDROID_HOME=C:\development\android-sdk
 +
SET APK_SDK_PLATFORM=C:\development\android-sdk\platforms\android-22
 +
SET APK_PROJECT_PATH=C:\Android\Projects\androidlcl\android
 +
 
 +
 
 +
and these lines:
 +
 
 +
REM Convert the java bytecode to dalvik bytecode
 +
::REM For older SDKs: call dx --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes
 +
::REM For older SDKs:  call java -Djava.ext.dirs=%ANDROID_HOME%\platform-tools\lib\ -jar %ANDROID_HOME%\platform-tools\lib\dx.jar --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes
 +
call java -Djava.ext.dirs=%ANDROID_HOME%\platform-tools\lib\;%APK_BUILD_TOOLS%\lib\ -jar %APK_BUILD_TOOLS%\lib\dx.jar --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes
 +
 
 +
 
 +
</syntaxhighlight>
 +
 
 +
 
 +
run "build_debug_apk.bat" answer at the questions and give the password "senhas" when asked
 +
 
 +
This will generate
  
 
C:\Android\Projects\androidlcl\android\bin\lcltest.apk [1.549 kb]
 
C:\Android\Projects\androidlcl\android\bin\lcltest.apk [1.549 kb]
  
* “Android Sanal Aygıt” Oluşturma
+
 
BAŞLAT > AVD Manager
+
* Create an Android Virtual Device
New > AVD name > Bir isim ver
+
START > AVD Manager
Device 5.1 WVGA
+
 
Hedef Android 4 API 14
+
New > AVD name > give a name
İş Tamam
+
 
Birkez oluşturulan sanal aygıtı seçin ve “start” > “Launch” birkaç dakika bekleyin.
+
Device 5.1 WVGA
 +
 
 +
Target Android 4 API 14
 +
 
 +
Hit OK
 +
 
 +
Once created select the virtual device and hit "start" > "Launch" wait a couple of minutes.
 
   
 
   
  
* “C:\Android\Projects\androidlcl\android\adb_install.bat” dosyasını Yazı editöründe düzenlemek için aç.
+
* Edit with a text editor
 +
C:\Android\Projects\androidlcl\android\adb_install.bat
  
Bu şekilde değiştirin :
+
Modify like this :  
 
<syntaxhighlight lang="dos">
 
<syntaxhighlight lang="dos">
 
REM Adjust these paths to yours
 
REM Adjust these paths to yours
Line 153: Line 212:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
"Adb_install.bat" dosyasını çalıştırın. Bu Sanal Aygıt içine "LCL Test" kuracak.
+
Run "adb_install.bat" . This will install the "LCL Test" into your Virtual device
  
  
* Hata Ayıklama(Debugging) işlemi.
+
* Debugging
“C:\Android\Projects\androidlcl\android\adb_install.bat” dosyasını Yazı editöründe düzenlemek için aç.
+
Edit with a text editor the file
  
Bu şekilde  değiştirin :
+
C:\Android\Projects\androidlcl\android\adb_install.bat
 +
 
 +
like this :
 
<syntaxhighlight lang="dos">
 
<syntaxhighlight lang="dos">
 
REM Adjust these paths to yours
 
REM Adjust these paths to yours
Line 169: Line 230:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Çalıştığında burada bir hata ayılama(Debug) dosyan olacak :
+
By running this you will get a debug file here :
  
“C:\Android\Projects\androidlcl\android\std.txt”
+
C:\Android\Projects\androidlcl\android\std.txt
  
“Tadını Çıkar” !  
+
Enjoy !
  
==Bağlantılar==
+
==Links==
  
* [http://forum.lazarus.freepascal.org/index.php/topic,22414.msg141964.html? Bu Yazının bulunduğu Orijinal Forum Konu Başlığı]
+
* [http://forum.lazarus.freepascal.org/index.php/topic,22414.msg141964.html? Original forum topic]
* [http://sourceforge.net/projects/laztoapk/files/Lazarus%20and%20Android.pdf/download Lazarus ve Android için Resimli PDF Öğreticisi]
+
* [http://sourceforge.net/projects/laztoapk/files/Lazarus%20and%20Android.pdf/download Lazarus and Android PDF tutorial with images]
  
 
=Linux=
 
=Linux=
  
* [http://pascalgeek.blogspot.cz/2013/10/android-programming-with-lazarus.html “Custom Draw ” Arayüzü aracılığıyla Lazarusla Android Programlama]
+
{{Note|Work in progress...}}
 +
 
 +
This is a quick tutorial on how to create android apps with Lazarus.
 +
 
 +
In this tutorial assume used versions are Ubuntu 13.10, OpenJDK 1.7.0_51, SDK 22.2.1, ndk-r9, Laz4Android1.1-41139-FPC2.7.1
 +
 
 +
==Prepare folder==
 +
Create directory ~\Android
 +
 
 +
==Install OpenJDK==
 +
<syntaxhighlight lang="bash">sudo apt-get install openjdk-7-jdk</syntaxhighlight>
 +
 
 +
==Install SDK==
 +
Go to http://developer.android.com/sdk/index.html
 +
 
 +
DOWNLOAD FOR OTHER PLATFORMS > SDK Tools Only
 +
 
 +
android-sdk_r22.6.2-linux.tgz (Recommended)
 +
 
 +
Extract SDK () into ~\Android\android-sdk
 +
<syntaxhighlight lang="bash">tar -zxvf android-sdk_r22.6.2-linux.tgz</syntaxhighlight>
 +
 
 +
 
 +
Now update the SDK (Start ~\Android\android-sdk\tools\android)
 +
 
 +
add android 4.0 (API 14)
 +
 
 +
add android 2.2 (API 8]
 +
 
 +
Install packages.
 +
 
 +
==Install NDK==
 +
http://developer.android.com/tools/sdk/ndk/index.html
 +
 
 +
Download only the file android-ndk-r9d-linux-x86.tar.bz2
 +
 
 +
Extract android-ndk-r9d-linux-x86.tar.bz2 into ~\Android\android-ndk-r9
 +
<syntaxhighlight lang="bash">tar -jxvf android-ndk-r9d-linux-x86.tar.bz2</syntaxhighlight>
 +
 
 +
==Build FPC 2.7.1==
 +
 
 +
Install latest FPC distribution package:
 +
<syntaxhighlight lang="bash">sudo apt-get install fpc</syntaxhighlight>
 +
 
 +
Download latest FPC trunk from SVN:
 +
<syntaxhighlight lang="bash">svn co http://svn.freepascal.org/svn/fpc/trunk/ ~/Android/fpcsrc</syntaxhighlight>
 +
 
 +
Build FPC trunk for ARM to ~/Android/fpc:
 +
<syntaxhighlight lang="bash">make crossinstall CPU_TARGET=arm OS_TARGET=linux \
 +
CROSSBINDIR=~/Android/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/arm-linux-androideabi/bin OPT=-dFPC_ARMEL INSTALL_PREFIX=~/Android/fpc</syntaxhighlight>
 +
 
 +
 
 +
==Rebuild Lazarus IDE==
 +
Run ~\Android\lazarus
 +
 
 +
Select "Start IDE"
 +
 
 +
select "Package" "Install/Uninstall Packages"
 +
 
 +
select customdrawn 0.0 > install selection and hit save and rebuild IDE , continue
 +
 
 +
 
 +
==Links==
 +
 
 +
* [http://pascalgeek.blogspot.cz/2013/10/android-programming-with-lazarus.html Android Programming with Lazarus through Custom Drawn Interface]
 +
 
 +
[[Category:Android]]
 +
[[Category:Tutorials]]

Latest revision as of 12:24, 28 January 2016

English (en) español (es) русский (ru)

Android robot.svg

This article applies to Android only.

See also: Multiplatform Programming Guide

Windows

This is a quick tutorial on how to create android apps with Lazarus.

In this tutorial assume used versions JDK 1.6u45 + SDK 22.2.1 + ndk-r9 + Laz4Android1.1-41139-FPC2.7.1

Prepare folder

Create on C:\ a folder called "Android"

Install JDK

1.6u45 (i have installed jdk-6u45-windows-x64.exe) arm-linux-androideabi/bin http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR

It will be installed in to C:\Program Files\Java\.

Install SDK

Go to http://developer.android.com/sdk/index.html

DOWNLOAD FOR OTHER PLATFORMS > SDK Tools Only

installer_r22.2.1-windows.exe (Recommended)

Install sdk (installer_r22.2.1-windows) into C:\Android\android-sdk

Copy at "C:\Android\android-sdk\tools" the file "apkbuilder.bat" (can be found here

https://github.com/ACSOP/android_sdk/raw/master/apkbuilder/etc/apkbuilder.bat )

Now update the SDK [WIN START > SDK Manager ]

add android 4.0 (API 14)

add android 2.2 (API 8]

Install packages.

Install NDK

http://developer.android.com/tools/sdk/ndk/index.html

Download only the file android-ndk-r9-windows-x86.zip

Unzip android-ndk-r9-windows-x86.zip into C:\Android\android-ndk-r9


Install Laz4Android

Download it from https://skydrive.live.com/?cid=89ae6b50650182c6&id=89AE6B50650182C6!149

New version can download from here:[1]

Unzip Laz4Android1.1-41139-FPC2.7.1.7z into C:\Android\laz4android

Copy

C:\Android\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-*.exe

to

C:\Android\laz4android\fpc\2.7.1\bin\i386-win32\*

Edit the file C:\Android\laz4android\build.bat like this :

SET FPC_BIN_PATH=C:\Android\laz4android

Run build.bat (doubleclick) -> It will compile & build lazarus.

Rebuild Laz4Android IDE

Run C:\Android\laz4android\lazarus.exe

Select "Start IDE"

select "Package" "Install/Uninstall Packages"

select customdrawn 0.0 > install selection and hit save and rebuild IDE , continue


Compile the demo "androidlcl"

Copy C:\Android\laz4android\examples\androidlcl at C:\Android\Projects\androidlcl

Run "C:\Android\laz4android\lazarus.exe"

File > open "C:\Android\Projects\androidlcl\androidlcltest.lpr"

Project > project options

Compiler options > select "Release TAndroid"

Paths >

Libraries -Ll : C:\Android\android-ndk-r9\platforms\android-8\arch-arm\usr\lib;C:\Android\android-ndk-r9\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\lib\gcc\arm-linux-androideabi\4.6

Target file name : android\libs\armeabi\liblclapp.so

Code generation

 Target OS -T android
 Target CPU -P arm
 Target processor default

Linking :

 Enable strip symbols (-Xs)

Other : -dANDROID -Xd -CpARMV6 -FLlibdl.so

Ide macro values : macro name : LCLWidgetType macro value : customdrawn

Now Run > Compile this will generate this library : C:\Android\Projects\androidlcl\android\libs\armeabi\liblclapp.so [5.073 kb]


Deployment

  • Edit with a text editor

C:\Android\Projects\androidlcl\android\generate_debug_key.bat

Modify the first 6 lines like this :

REM Adjust these paths to yours
SET PATH=C:\Android\android-sdk\tools;C:\Android\android-sdk\build-tools\17.0.0;C:\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_45\bin
SET APP_NAME=lcltest
SET ANDROID_HOME=C:\Android\android-sdk
SET APK_SDK_PLATFORM=C:\Android\android-sdk\platforms\android-8
SET APK_PROJECT_PATH=C:\Android\Projects\androidlcl\android

Run "generate_debug_key.bat"

Use as password : "senhas"

This will produce the file :

C:\Android\Projects\androidlcl\android\bin\LCLDebugKey.keystore


  • Edit with a text editor

C:\Android\Projects\androidlcl\android\build_debug_apk.bat

Modify the first 6 lines like this :

REM Adjust these paths to yours
SET PATH=C:\Android\android-sdk\tools;C:\Android\android-sdk\build-tools\17.0.0;C:\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_45\bin
SET APP_NAME=lcltest
SET ANDROID_HOME=C:\Android\android-sdk
SET APK_SDK_PLATFORM=C:\Android\android-sdk\platforms\android-8
SET APK_PROJECT_PATH=C:\Android\Projects\androidlcl\android


I had to change mine to this on sdk version 22:

SET APK_BUILD_TOOLS=C:\development\android-sdk\build-tools\22.0.1
SET PATH=C:\development\android-sdk\tools;C:\development\android-sdk\platform-tools\;C:\Program Files\Java\jdk1.7.0_79\bin;%APK_BUILD_TOOLS%
SET APP_NAME=androidlcl
SET ANDROID_HOME=C:\development\android-sdk
SET APK_SDK_PLATFORM=C:\development\android-sdk\platforms\android-22
SET APK_PROJECT_PATH=C:\Android\Projects\androidlcl\android


and these lines:

REM Convert the java bytecode to dalvik bytecode
::REM For older SDKs: call dx --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes
::REM For older SDKs:  call java -Djava.ext.dirs=%ANDROID_HOME%\platform-tools\lib\ -jar %ANDROID_HOME%\platform-tools\lib\dx.jar --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes
call java -Djava.ext.dirs=%ANDROID_HOME%\platform-tools\lib\;%APK_BUILD_TOOLS%\lib\ -jar %APK_BUILD_TOOLS%\lib\dx.jar --dex --verbose --output=%APK_PROJECT_PATH%\bin\classes.dex %APK_PROJECT_PATH%\bin\classes


run "build_debug_apk.bat" answer at the questions and give the password "senhas" when asked

This will generate

C:\Android\Projects\androidlcl\android\bin\lcltest.apk [1.549 kb]


  • Create an Android Virtual Device

START > AVD Manager

New > AVD name > give a name

Device 5.1 WVGA

Target Android 4 API 14

Hit OK

Once created select the virtual device and hit "start" > "Launch" wait a couple of minutes.


  • Edit with a text editor

C:\Android\Projects\androidlcl\android\adb_install.bat

Modify like this :

REM Adjust these paths to yours
SET PATH=C:\Android\android-sdk\tools;C:\Android\android-sdk\build-tools\17.0.0;C:\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_45\bin

adb uninstall com.pascal.lcltest
adb install bin\lcltest.apk

pause

Run "adb_install.bat" . This will install the "LCL Test" into your Virtual device


  • Debugging

Edit with a text editor the file

C:\Android\Projects\androidlcl\android\adb_install.bat

like this :

REM Adjust these paths to yours
SET PATH=C:\Android\android-sdk\tools;C:\Android\android-sdk\build-tools\17.0.0;C:\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_45\bin

adb logcat > std.txt

pause

By running this you will get a debug file here :

C:\Android\Projects\androidlcl\android\std.txt

Enjoy !

Links

Linux

Light bulb  Note: Work in progress...

This is a quick tutorial on how to create android apps with Lazarus.

In this tutorial assume used versions are Ubuntu 13.10, OpenJDK 1.7.0_51, SDK 22.2.1, ndk-r9, Laz4Android1.1-41139-FPC2.7.1

Prepare folder

Create directory ~\Android

Install OpenJDK

sudo apt-get install openjdk-7-jdk

Install SDK

Go to http://developer.android.com/sdk/index.html

DOWNLOAD FOR OTHER PLATFORMS > SDK Tools Only

android-sdk_r22.6.2-linux.tgz (Recommended)

Extract SDK () into ~\Android\android-sdk

tar -zxvf android-sdk_r22.6.2-linux.tgz


Now update the SDK (Start ~\Android\android-sdk\tools\android)

add android 4.0 (API 14)

add android 2.2 (API 8]

Install packages.

Install NDK

http://developer.android.com/tools/sdk/ndk/index.html

Download only the file android-ndk-r9d-linux-x86.tar.bz2

Extract android-ndk-r9d-linux-x86.tar.bz2 into ~\Android\android-ndk-r9

tar -jxvf android-ndk-r9d-linux-x86.tar.bz2

Build FPC 2.7.1

Install latest FPC distribution package:

sudo apt-get install fpc

Download latest FPC trunk from SVN:

svn co http://svn.freepascal.org/svn/fpc/trunk/ ~/Android/fpcsrc

Build FPC trunk for ARM to ~/Android/fpc:

make crossinstall CPU_TARGET=arm OS_TARGET=linux \
CROSSBINDIR=~/Android/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/arm-linux-androideabi/bin OPT=-dFPC_ARMEL INSTALL_PREFIX=~/Android/fpc


Rebuild Lazarus IDE

Run ~\Android\lazarus

Select "Start IDE"

select "Package" "Install/Uninstall Packages"

select customdrawn 0.0 > install selection and hit save and rebuild IDE , continue


Links