You are on page 1of 20

Custom Drawn Interface/Android

Contents
    

  

1 Architecture 2 Roadmap 3 Using the Android SDK, Emulator and Phones 4 Android Programming 5 Configuring the Free Pascal Compiler for Android o 5.1 Use the ready Virtual Box Image with FPC and Lazarus o 5.2 Building the compiler yourself in Windows o 5.3 Using the pre-compiled compiler in Windows o 5.4 Building the compiler yourself in Linux o 5.5 Using the pre-compiled compiler in Linux 6 Install the Java JDK and the Android SDK and NDK 7 Compiling the example LCL Android Application 8 How to create an LCL Android Application o 8.1 Step 1 - Creating the LPI o 8.2 Step 2 - Building the library o 8.3 Step 3 - Create the Android project structure o 8.4 Step 4 - Creating the APK package  8.4.1 Step 4 - Creating the APK package in Linux  8.4.2 Step 4 - Creating the APK package in Windows o 8.5 Building an LCL Android application with debug info 9 Oh no! My LCL Android application doesn't work o 9.1 The Pascal executable was compiled for a wrong architecture, operating system and/or widgetset o 9.2 My Pascal application crashed. How to get a stacktrace? o 9.3 The indispensable build options o 9.4 Wrong package name 10 Free Pascal Bugs on Android Support o 10.1 FPC4Android Branches  10.1.1 FPC4Android 2.5.1  10.1.2 FPC4Android 2.6.1 11 Android SDK and NDK bugs o 11.1 Android NDK for Windows broken linker o 11.2 Error while calling DX: Trouble processing: bad class file magic (cafebabe) 12 Development Notes o 12.1 The mysterious JNI Crash o 12.2 NDK Libraries available in Android 2.2 (API level 8) o 12.3 Native text drawing o 12.4 Flood of garbage collector messages when the caret is visible o 12.5 Why the caret of a TEdit keeps blinking after clicking on the form o 12.6 Android ComboBox o 12.7 Using the Native ListView Dialog o 12.8 LazDeviceAPIs

Architecture
LCL-CustomDrawn-Android utilizes a minimal Java application which communicates with our Pascal library and sends all events to it and also obeys commands from it. The communication is done via JNI as supported by Google. The controls are not native, instead they are all drawing using TRawImage+TLazIntfImage+TLazCanvas and events and the painting are clipped using LazRegions. The drawing itself is done in Pascal using jnigraphics to draw on a Bitmap Java object which is then drawn by the minimal Java activity on a SurfaceView. Our previous and short-lived attempt to write an LCL Interface for Android (LCL-Android) utilized a non-standard method of using native executables which communicated with a Java machine via Pipes. This method was abandoned because it was considered unsupported by Google. It is considered obsolete and people should use LCL-CustomDrawn-Android instead. This older interface was documented in Android Interface.

Roadmap
Part 1, until March 2012: 1. 2. 3. 4. 5. 6. Build the set of Lazarus Custom Drawn Controls Initial bindings for the Android APIs Create an application to automatically generate the bindings Start the new widgetset Implement support for JNI Merge the Lazarus Custom Drawn Controls into the LCL and use them to implement all basic controls 7. Add text support for Android 8. Implement basic window client area scrolling 9. Add mobile emulator for desktop platforms 10. Improve the mobile scrolling 11. Add text support in X11 12. Add DPI awareness and adaptation in the LCL 13. Add non-native text support via pasfreetype Part 2: April, May, June 2012: 1. 2. 3. 4. TButton improve the Android visual TBitBtn TRadioButton finish the native look Calendar dialog -> Problematic as the LCL has no calendar dialog, it just opens a normal form and puts a calendar on it, so we need a TCDCalendar widget 5. MaskEdit 6. Improve TComboBox 7. TMemo 8. TListView as a list with columns 9. TMainMenu 10. Database with sqlite 11. Barcode reading 12. Windows add-on installer 13.

KDE. the Android NDK.Using the Android SDK.1 of FPC. Note that the virtual machine contains the Lazarus source code from when it was created. Emulator and Phones Custom Drawn Interface/Using the Android SDK.vbox” and “Android Devel VM. . subversion and everything else necessary for building Android applications with Lazarus. Then one can already use this Linux virtual machine to build Android applications. so it needs to be unzipped.2GB.9.31. Use the ready Virtual Box Image with FPC and Lazarus The fastest way to configure Free Pascal and Lazarus for Android development is simply using a preconfigured virtual machine image which already includes Mageia Linux 1. however. Free Pascal for both x86-linux and arm-linux (targetting Android). The process of building an application involves first opening Lazarus and building the application in Lazarus.apk. Ant. for example the example project available on ~/Programas/lazarus/example/androidlcl/ and then going into the Linux terminal. since support for the Android target is present in the trunk (development) version 2. the Android SDK. navigating to ~/Programas/lazarus/example/androidlcl/android and issuing the command “ant debug” which will generate the APK file in ~/Programas/ lazarus/example/androidlcl/android/bin/LCLExample-debug.Install the Android SDK and NDK Download from Google and install both the SDK and the NDK for Windows. The download like for the virtual machine image is: https://sourceforge. as the trunk version might ocasionally contain problems. Here are up to date instructions: building a cross-compiler for Android target. The virtual machine image is composed by two files: “Android Devel VM. The Mac OS X default zip application can. the GNU debugger (GDB). Note that this involves some risks.vbox file. Lazarus 0. Subversion. After unzipping the VM image has 5. and PeaZip too and WinRAR too. Building the compiler yourself in Windows Step 1 . Java. Gtk2 and all it's development packages.hdd”. To use this virtual machine one should install Virtual Box and then use it to open the .7. Emulator and Phones Android Programming Configuring the Free Pascal Compiler for Android NOTE: The cross-compiler instructions below are probably obsolete. There are two users in the virtual machine: “root” and “pascaldev” and both of them use the password “root”. Both need to be located in the same folder and also note that the source forge download is a zipped file. Both 7-Zip and the Windows 7 default unzipper fail.net/projects/ptools/files/Lazarus_for_Android_VM_Image/snapshot_30_dez_2011/ (warning: the VirtualBox image was created using the Mac OS X default Zip utility and not all zip applications can handle it. but one can also use svn update to get the latest code.

for NDK r7 installed in C:\Programas\android-ndk-r7\ the path is C:\Programas\android-ndk-r7\toolchains\arm-linuxandroideabi-4. For example.4.4.exe C:\Programas\android-ndk-r7\toolchains\armlinux-androideabi-4.5.1 from January 19th Create a folder to store the FPC trunk source code and checkout revision 16790 Or if you want support for database and many other nice fixes use the branch fpc4android from here: svn co https://p-tools.4.4.4.4.3\prebuilt\windows\bin\arm-linux-androideabi-strip.Check your path to the binutils installed by the NDK.exe And copy and then rename to have: C:\Programas\fpcandroid\output\bin\i386-win32\arm-linux-as.4\bin\i386-win32\ make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=C:\Programas\androidndk-r7\toolchains\arm-linux-androideabi-4.Create the build script and built it Create the output directory.2.bat in the fpc root folder.4.3\prebuilt\windows\bin OPT=-dFPC_ARMEL BINUTILSPREFIX=arm-linux-androideabi.exe C:\Programas\fpcandroid\output\bin\i386-win32\arm-linux-strip.3\prebuilt\windows\bin\arm-linux-androideabi-ld.3\prebuilt\windows\bin\arm-linuxandroideabi-as.exe C:\Programas\android-ndk-r7\toolchains\arm-linux-androideabi4. let's say you install this Lazarus version in C:\Programas\lazarusfpc244 Step 4 .exe C:\Programas\fpcandroid\output\bin\i386-win32\arm-linux-ld. for example: C:\Programas\fpcandroid\output Next create a file called build.net/svnroot/p-tools/fpc4android fpc4android Step 3 .sourceforge.4.exe . For example.INSTALL_PREFIX=C:\Programas\fpcandroid\output pause Next run this batch script and you should have FPC installed into C:\Programas\fpcandroid\output Step 5 .Copy some cross-binutils into the bin dir You now should have a FPC binary in C:\Programas\fpcandroid\output\bin\i386-win32 Now get these 3 files: C:\Programas\android-ndk-r7\toolchains\arm-linux-androideabi-4. For example. in our example C:\Programas\fpcandroid and copy to it: SET PATH=C:\Programas\lazarusfpc244\fpc\2.4 An easy way to obtain a good FPC 2.Download FPC 2.9.Install FPC 2.3\prebuilt\windows\bin Also check your path to the libraries installed by the NDK.svn.30. for NDK r7 installed in C:\Programas\android-ndk-r7\ the path is C:\Programas\android-ndk-r7\platforms\android-8\archarm\usr Step 2 .4 is installing Lazarus 0.

7.com/technetwork/java/javase/downloads/index.Install the Java JDK and the Android SDK and NDK If you haven't done so already.6. download the SDK r20 from this link: http://dl. then install the Java JDK and the Android SDK and NDK.html Android SDK Download (!WARNING! Instead of clicking in the first download link that you see.Download and unzip the pre-compiled compiler The download is available here: https://sourceforge. and I tested that 8c works fine.Step 6 .0 or 2.1\units\ Now create a directory C:\Programas\lazarus31\fpc\2.1 !) Now you can already build the example project androidlcltest.6.oracle. so might be 2. go to "Use an existing IDE"!): http://developer.exe Android NDK version 7 download link: http://dl.1\units\arm-linx and copy fpc4android_2_5_1_26_mar_2012\units\arm-linux there Copy all .1 or something else) Step 3 .6.com/android/installer_r20-windows.6.Merge it into the FPC installation Let's say you have the following Lazarus C:\Programas\lazarus31 with the following fpc installed inside it: C:\Programas\lazarus31\fpc\2.google.1\bin\i386-win32 and C:\Programas\lazarus31\fpc\2.com/sdk/index. not the version of the cross-compiler.6.net/projects/ptools/files/Free%20Pascal%20for%20ARM/Windows/ Step 2 .5.1\units\ Now create a directory C:\Programas\lazarus31\fpc\2.zip .google.bat script which is utilized in our build system in Windows.exe files from fpc4android_2_5_1_26_mar_2012\bin\i386-win32\ into C:\Programas\lazarus31\fpc\2. If you want to use our Windows build scripts.1\units\arm-linux and copy C:\Programas\fpcandroid\output\units\arm-linux there Copy all .1\bin\i386-win32 (! copy the exe-files to FPC 2.android.6.Merge this into a Lazarus FPC setup Let's say you have the following Lazarus C:\Programas\lazarus31 with the following fpc installed inside it: C:\Programas\lazarus31\fpc\2. I recommend the JDK 6 (JDK 7 doesnt work!).1\bin\i386-win32 (the version here should be of the installed Windows compiler.    Java JDK (!WARNING! Download JDK version 6! Version 7 does not work!!!): http://www.exe files from C:\Programas\fpcandroid\output\bin\i386-win32\ into C:\Programas\lazarus31\fpc\2.html !WARNING! The SDKs r21 and superior removed the nice apkbuilder.1\bin\i386-win32 and C:\Programas\lazarus31\fpc\2.5.com/android/ndk/android-ndk-r7windows.6.lpi using the Windows-Release build mode Using the pre-compiled compiler in Windows Step 1 . latest SDK and the NDK version 7. The Windows NDK 7b has a serious bug: [1] Some people also report that 7c works fine.6.

1: Required Environment  The latest stable FPC installed in the system via the RPM / DEB / TAR package Step 1 .Configure the cross-binutils The assembler needs a parameter to tell it which ARM ABI to use.lpi using the Windows-Release build mode and these instructions: Custom Drawn Interface/Android#Compiling_the_example_LCL_Android_Application Building the compiler yourself in Linux See Setup_Cross_Compile_For_ARM and make sure to use the option OPT="-dFPC_ARMEL" for building the compiler.0 and 2010. which are the crossbinutils can be found here: http://rpm.4-2mnb2.1.net/index.20. These commands will do it: su mv /usr/bin/arm-linux-as /usr/bin/arm-linux-as_org gedit /usr/bin/arm-linux-as Now paste into the editor this code: . but one can simply ignore this problem and it works fine using --nodeps: rpm -ivh --nodeps cross-arm-binutils-2.rpm In Mandriva Linux 2010.i586. we will rename the original assembler and substitute it with a shell script which passes the desired parameter.51. The following steps were tested in Mandriva Linux 2010.4-2mnb2.rpm.0.20.0. A choice which works good is EABI-5. or else read the instructions for building the cross-binutils yourself at Setup_Cross_Compile_For_ARM Step 2 .i586. arm-linux-ld.html Just download the RPM package and install it using: rpm -ivh cross-arm-binutils-2.Install the cross-binutils For Mandriva Linux the RPM package containing arm-linux-as.php3/stat/4/idpl/14252825/dir/mandriva_2010/com/cross-arm-binutils2.51.Now you can already build the example project androidlcltest.20. etc. which is compatible with all Android devices available as of Jan 2011. Using the pre-compiled compiler in Linux A pre-compiled compiler is provided for convenience for users.i586.0 the dependencies won't match.rpm For other distributions use the corresponding package.4-2mnb2.pbone.51.0. To set this. as the package is for 2010.

then you configured the cross-compiler correctly. so try to call it like this: [felipe@localhost Programas]$ /usr/bin/ppcrossarm If this command works and fpc shows its options.android.lpi using the Windows-Release build mode and these instructions: Custom Drawn Interface/Android#Compiling_the_example_LCL_Android_Application .net/projects/ptools/files/Free%20Pascal%20for%20ARM/ Then use these commands to install the pre-compiled Free Pascal cross-compiler into /usr: [felipe@localhost Programas]$ ls -l total 20664 -rw-rw-r-. I recommend the JDK 6 (JDK 7 doesnt work!).oracle.5. the old compiler will automatically find the new compiler and it's object files.5.cfg file isn't necessary.arm-linux.gz [felipe@localhost Programas]$ su Password: [root@localhost Programas]# cp fpc-2.google. The Windows NDK 7b has a serious bug: [2] Some people also report that 7c works fine.Verify if your Cross-Compiler works If you made no errors in the previous steps.tar.tar.1/ppcrossarm /usr/bin/ppcrossarm Step 4 .#!/bin/sh /usr/bin/arm-linux-as_org -meabi=5 $@ And don't forget to then make it executable: chmod 755 /usr/bin/arm-linux-as Step 3 .zip Now you can already build the example project androidlcltest. latest SDK and the NDK version 7.1.5.tar.arm-linux.1 felipe felipe 17098552 2010-10-25 08:17 fpc-2.gz [root@localhost usr]# ln -s /usr/lib/fpc/2.1.gz /usr/ [root@localhost Programas]# cd /usr/ [root@localhost usr]# tar -xvf fpc-2. and I tested that 8c works fine.html Android SDK Download (Choose Use an existing IDE!): http://developer.1.com/technetwork/java/javase/downloads/index.com/android/ndk/android-ndk-r7windows.5.arm-linux. if not.    Java JDK (Choose version 6!): http://www. Install the Java JDK and the Android SDK and NDK If you haven't done so already.com/sdk/index.html Android NDK version 7 download link: http://dl. it should work.Install the Free Pascal Cross-Compiler At this point the pre-compiled FPC can be download from here: http://sourceforge. then install the Java JDK and the Android SDK and NDK. then try to find out if your symbolic link points to a correct location with this command: [felipe@localhost Programas]$ ls -ls /usr/bin/ppc* Now we are ready to compile Android applications using the Lazarus IDE! Configuring the fpc.

The image bellow shows where to configure this: .lpi Step 2 .Make sure you have the Java JDK and the Android SDK and NDK installed Read here: Custom_Drawn_Interface/Android#Install_the_Java_JDK_and_the_Android_SDK_and_NDK Step 3 .so.2+ like the LCL. libraries are located for your target Android API level. because it supports Android 2. libc.Download the source code The source code of the example is located inside the Lazarus sources in lazarus/examples/androidlcl/androidlcltest. To hardcode the compiler path in cause of trouble go to the menu "Tools->Options" and change the "Compiler Path" to "/usr/bin/ppcrossarm" But it is necessary to configure the LPI file to build the example.so.lpi project and go to the section Paths and change the libraries path to reflect the correct paths of where your Android NDK was installed and where your jnigraphics. For LCL-CustomDrawn-Android API level 8 is the best choice. but if you have trouble in this part you can try to hard code the compiler path to use the new crosscompiler. etc.Build the project using the Lazarus IDE Configuring Lazarus itself to use the new compiler should not normally be necessary because fpc should be able to find the symlink created. Open the Project Options dialog of the androidlcltest.Compiling the example LCL Android Application Step 1 .

go to the command line and issue these commands: cd lazarus/examples/androidlcl/android ant debug The APK will be located in lazarus/examples/androidlcl/android/bin Step 5 . Do not modify this file -. Step 4 .YOUR CHANGES WILL BE ERASED! This file must *NOT* be checked in Version Control Systems. they create a . but ignore that and modify it anyway.so .Build the APK If you are using Windows. Here is how the file looks like: # # # # # This file is automatically generated by Android Tools. sdk.so. So you have to change this manually in lazarus.The actual lazarus release contains a error.dir=/home/felipe/Programas/android-sdk-linux After configuring that one.properties and change it to reflect your Android SDK path. This is only used by Ant # For customization when using a Version Control System. please read the # header note.file instead of a . as it contains information specific to your local configuration.so . # location of the SDK. You should see this: . use these instructions to build the APK: Custom Drawn Interface/Android#Step_4_-_Creating_the_APK_package_in_Windows If you are using Linux follow these instructions instead: Before going to the command line to build the APK open the file lazarus/examples/androidlcl/android/local. The file says you should not modify it.file.Install the APK in your phone and run it You can install via ADB or by copying the file to the sdcard.

widgetset. as shown in these screenshots: . This example can be obtained from the Lazarus source tree in lazarus/examples/androidlcl Then you will need to modify the build files to change them to your new project name and your new Java package name.How to create an LCL Android Application To create a new LCL-CustomDrawn-Android application simply copy all of the file structure and build and java files from the example project called "androidlcl".Creating the LPI You need a separate LPI at the moment for the Android version of the application but all the rest of the code can be shared. Create it using the template for a "Library" and then adapt the code from the example located in the lazarus source code in lazarus/examples/androidlcl You need to adapt the exported JNI method names to your Android Package Name. Step 2 . Step 1 . This debug information is not so useful in Android and makes the executable much bigger. build the Pascal executable without debug information.Building the library First of all. Open the menu Project->Project Options and set the build mode. architecture and operating system targets.

.

Create the Android project structure Besides the LCL project building. Step 4 .apk cd myproject/android ant debug Ant and all dependencies must be installed using the package management of your linux distribution.oracle.C:\Programme\Android\androidsdk\platform-tools\. The package name needs to be updated in the build files. Things to change are the path to the SDK.Creating the APK package in Windows Pre-requisites:   Java JDK installed: http://www.com/technetwork/java/javase/downloads/index. To do this use this script: lazarus/examples/androidlcl/android/generate_debug_key. Step 4 .Step 3 . such as configuring a proper LPI and having a library main project file. First it is necessary to create a debug key to use.6. the package name. in the activity java source code and also in the main library pascal source in the exports section.C:\Programme\Java\jdk1. Simply copy from the example project in lazarus/examples/androidlcl and adapt it to the new project.Creating the APK package Step 4 . The package will be in android/bin/MyProject.Creating the APK package in Linux To create the APK package in Linux simply go to the directory "android" inside the project folder and issue the command "ant debug". it contains following: REM Adjust these paths to yours SET PATH=C:\Programme\Android\android-sdk\tools.keystore -alias LCLDebugKey -keyalg RSA -validity 10000 .0_38\bin SET APP_NAME=androidlcltest SET ANDROID_HOME=C:\Programme\Android\android-sdk SET APK_SDK_PLATFORM=C:\Programme\Android\android-sdk\platforms\android-9 SET APK_PROJECT_PATH=C:\Programme\lazarus\examples\androidlcl\android mkdir bin keytool --help keytool -genkey -v -keystore bin\LCLDebugKey.bat which can be copied from the example application to your own project folder.html Android SDK Installed Instructions: In Windows we provide a APK build system which uses only the tools provided in the Android SDK and therefore does not require ANT. in the directory structure android/src/packagename. one also needs to add all of the android project structure.

ap_ bin\%APP_NAME%.java REM DX to convert the java bytecode to dalvik bytecode call dx --dex --verbose -output=%APK_PROJECT_PATH%\bin\classes. use the other script: lazarus/examples/androidlcl/android/build_debug_apk.apk raw\lib\armeabi\*.xml -F bin\%APP_NAME%.dex .C:\Programme\Android\androidsdk\platform-tools\.6. Don't forget adjusting the android version from APK_SDK_PLATFORM! After generating the key.ap_ -f %APK_PROJECT_PATH%\bin\classes.apk -v -u z %APK_PROJECT_PATH%\bin\%APP_NAME%.REM call and pause together allow us to see the results in the end pause You have to fix everything after SET to your own paths.so raw\lib\armeabi\ REM Resource compilation call aapt p -v -f -M AndroidManifest. This script contains the following: REM Adjust these paths to yours SET PATH=C:\Programme\Android\android-sdk\tools.C:\Programme\Java\jdk1.ap_ I %APK_SDK_PLATFORM%\android.bat To build the APK file.apk call apkbuilder %APK_PROJECT_PATH%\bin\%APP_NAME%-unsigned. Also remember to edit this batch file to reflect your paths.0_38\bin SET APP_NAME=androidlcltest SET ANDROID_HOME=C:\Programme\Android\android-sdk SET APK_SDK_PLATFORM=C:\Programme\Android\android-sdk\platforms\android-9 SET APK_PROJECT_PATH=C:\lazarus\examples\androidlcl\android REM Create necessary directory Structure mkdir bin mkdir bin\classes mkdir gen mkdir gen\com mkdir gen\com\pascal mkdir gen\com\pascal\lcltest mkdir raw mkdir raw\lib mkdir raw\lib\armeabi REM del del del Cleanup bin\%APP_NAME%.jar -d bin\classes src\com\pascal\lcltest\LCLActivity.dex %APK_PROJECT_PATH%\bin\classes REM It seams that dx calls echo off @echo on REM Now build the unsigned APK del %APK_PROJECT_PATH%\bin\%APP_NAME%-unsigned.jar -S res -m -J gen raw REM Java compiler call javac -verbose -classpath %APK_SDK_PLATFORM%\android.so REM More directory preparation copy libs\armeabi\*.

REM Generating on the fly a debug key rem keytool -genkey -v -keystore bin\LCLDebugKey.apk LCLDebugKey REM Align the final APK package zipalign -v 4 bin\%APP_NAME%-unaligned.apk REM call and pause together allow us to see the results in the end pause Don't forget changing the set-variables in the top AND change the pw (see above where). Building an LCL Android application with debug info It is useful to add another Android build mode which has debug info.apk bin\%APP_NAME%-unsigned.keystore -alias LCLDebugKey keyalg RSA -validity 10000 -dname NAME -storepass senhas -keypass senhas REM Signing the APK with a debug key del bin\%APP_NAME%-unaligned. Use all of the same options as shown above. except for the debug information: Oh no! My LCL Android application doesn't work .keystore -keypass senhas -storepass senhas -signedjar bin\%APP_NAME%-unaligned.apk REM Change keypass and storepass pw here| and here| jarsigner -verbose -keystore bin\LCLDebugKey.apk bin\%APP_NAME%.

See http://groups.com/group/android-ndk/msg/2ed2286e85f4ccdd? The indispensable build options      -Xd This build option is indispensable when cross-compiling from x86-linux to Android or else FPC will try to link the application against for example /usr/lib/libc.so If it mentions anything like 80386 or gtk. androidlcltest. not for Android like it should.so. "linux" operating system and "arm" architecture. Then set these in the dialog all options as explained in this section: How_to_build_an_LCL_Android_application To check if you library is arm-linux or not. The most important thing to do when an app doesn't work is to open the logcat and see what the log says. even if you specify a -Fl library path -CpARMV6 This build option is indispensable because code generated for older ARM versions is unsupported by Android and might crash in some devices. execute the following commands: cd libs/armeabi ls -l file liblclapp.so.google. My Pascal application crashed. This can be done by running this command line command: . then your program was compiled for linux-x86 and gtk2. How to get a stacktrace? If a Pascal application crashes you should use the command "adb logcat" to obtain the stack Read also this thread in the Google NDK group about converting addresses to lines: http://groups. such as libc.lpr in this part: .so in the NDK. This is done by going into the menu Project->Project Options. liblog.There are various reasons why the app may not work. Always verify that you compiled the program to the "android" widgetset.so ldd liblclapp.so. libjni.so instead of the libc./adb logcat And then test one of the hipotesis in the next subsections. In the example project this is done in the main project file. operating system and/or widgetset This is the leading cause of executables not running.com/group/android-ndk/browse_thread/thread/ba542483f062a828 -dAndroid in the package LCLBase. The Pascal executable was compiled for a wrong architecture.google. then you need to adapt the main project file to inform the widgetset of the change.lpk -Parm -Tlinux for the process and target operating system -Fl should contain the path to the NDK directory with the target link shared object. etc Wrong package name If you change the package name of the project.

org/view.freepascal.cgi?view=rev&revision=19036 broke linking Android projects We are in contact with FPC developers to fix the situation as can be seen in: http://mantis.freepascal.sourceforge.svn.myapp.net/projects/ptools/files/Free%20Pascal%20for%20ARM/ On February this revision http://svn.php?id=20726 FPC4Android Branches Because of FPC bugs related to Android support I have rolled my own branches. Free Pascal Bugs on Android Support The following summarizes the state of Android Support in Free Pascal:    The pre-compiled snapshot for x86-linux -> Android is known to work very well and it was built on 19th January 2011: https://sourceforge.freepascal.freepascal.net/projects/p-tools/files/Free%20Pascal%20for%20ARM/ To download the source execute: svn co https://p-tools. patches are welcome.6.php?id=19559 And I have created a pre-compiled x86-linux -> android-arm cross-compiler and hosted it here (it is the -v2 cross-compiler).php?id=18833 In the end of 2011 this revision http://svn.php?id=21341 http://bugs.1 This branch is not finished. it lacks patches to fix Android support.org/view.1 has the following fixes applied to it: http://bugs. FPC4Android 2. SVN link: svn co https://p-tools.CDWidgetset.5.org/cgibin/viewvc.net/svnroot/p-tools/fpc4android_2_6 fpc4android_2_6 .5.php?id=21208 http://bugs.freepascal.org/view. then you should change the command above to this: CDWidgetset.ActivityClassName := 'com/pascal/lcltest/LCLActivity'.ActivityClassName := 'com/pascal/myapp/LCLActivity'.pascal.org/cgibin/viewvc. If your new package name is com. https://sourceforge.org/view.freepascal.net/svnroot/p-tools/fpc4android fpc4android FPC4Android 2.freepascal.1 FPC4Android 2.org/view.cgi?view=rev&revision=16981 introduced this bug: http://mantis.sourceforge.svn.

html Development Notes The mysterious JNI Crash See the thread: http://groups..class.google.3\prebuilt\windows\bin\arm-linux-androideabi-ld. Alcatel and in the emulator with SIGILL but not in Xperia Mini..com/technetwork/java/javase/downloads/jdk6-downloads-1637591. The answer was that one needs to specify -CpARMV6 when building because older instructions might fail in some devices NDK Libraries available in Android 2...oracle..\com\pascal\djpalm\LCLActivit y$2..exe) crashes for no reason while linking LCL apps =( The linker from android-ndk-r7 and r5 work correctly.while processing com/pascal/djpalm/LCLActivity$1.4.while processing com/pascal/djpalm/LCLActivity$2.com/questions/8538891/bad-class-file-magic-when-using-dx-bat http://www.GetEnv would crash in HTC Wildfire.class processing D:\djsystem\djpalm\android\bin\classes\.0000) . Please install JDK 6 and use that instead.class .2 (API level 8) ..com/group/android-ndk/browse_thread/thread/ba542483f062a828 The problem was that vm^^. Unfortunatelly the current Android SDK r20 is not compatible with JDK 7.class. See:   http://stackoverflow....Android SDK and NDK bugs Android NDK for Windows broken linker The linker in android-ndk-r7b (path C:\Programas\android-ndk-r7\toolchains\arm-linux-androideabi4.while parsing com/pascal/djpalm/LCLActivity$1.while parsing com/pascal/djpalm/LCLActivity$2.google..class processing D:\djsystem\djpalm\android\bin\classes\.class. Motorola Atrix and other smartphones.0000) . trouble processing: bad class file magic (cafebabe) or version (0033.. HTC Desire HD.\com\pascal\djpalm\LCLActivit y$1.class . trouble processing: bad class file magic (cafebabe) or version (0033. only with JDK 5 and 6..com/group/android-ndk/browse_thread/thread/d8c88bd58ad6df87 Error while calling DX: Trouble processing: bad class file magic (cafebabe) If while using the build script you get the following errors: D:\djsystem\djpalm\android>call dx --dex --verbose --output=D:\djsystem\djpalm\a ndroid\bin\classes.\com\pascal\djpalm\LCLActivit y$3. This probably means that you are using JDK 7. See http://groups.dex D:\djsystem\djpalm\android\bin\classes processing D:\djsystem\djpalm\android\bin\classes\..

OpenGL ES 2 5. so the GC needs to collect the bitmaps and other paint objects when painting that often. libdl. . libm. It can draw on the ARGB 32-bits non-premultiplied format which is a pretty good one Flood of garbage collector messages when the caret is visible Something like this: D/dalvikvm( D/dalvikvm( D/dalvikvm( D/dalvikvm( D/dalvikvm( D/dalvikvm( D/dalvikvm( D/dalvikvm( D/dalvikvm( D/dalvikvm( D/dalvikvm( 6364): 6364): 6364): 6364): 6364): 2825): 6364): 6364): 6364): 6364): 6364): GC_EXTERNAL_ALLOC GC_EXTERNAL_ALLOC GC_EXTERNAL_ALLOC GC_EXTERNAL_ALLOC GC_EXTERNAL_ALLOC GC_EXPLICIT freed GC_EXTERNAL_ALLOC GC_EXTERNAL_ALLOC GC_EXTERNAL_ALLOC GC_EXTERNAL_ALLOC GC_EXTERNAL_ALLOC freed 188 objects / freed 170 objects / freed 162 objects / freed 162 objects / freed 162 objects / 371 objects / 18480 freed 162 objects / freed 162 objects / freed 162 objects / freed 162 objects / freed 162 objects / 6664 bytes in 6160 bytes in 5904 bytes in 5856 bytes in 5872 bytes in bytes in 91ms 5896 bytes in 5896 bytes in 5896 bytes in 5920 bytes in 5920 bytes in 94ms 78ms 82ms 78ms 80ms 78ms 78ms 81ms 78ms 83ms In my investigation this happens probably because the TCDEdit will request a full control invalidate on each timer tick. But there are also good things about it:   It can draw on a transparent bitmap and use alpha transparency to implement anti-aliasing and subpixel rendering.so (linker) 3.so 2.google. OpenGL ES 1 4. which currently will main a full form invalidate. See http://code.so LCL-CustomDrawn-Android uses libjnigraphics. liblog.so 6.setTextSize represents.so 9. libz. but to me it looks something else because it seams to differ across devices.LCL-CustomDrawn targets Android 2. libjnigraphics.com/p/android/issues/detail?id=393 There is no documentation about what the size in Paint.so at the moment. libstdc++. Some people say it is pixels. The text gets quite beaultiful. libthread_db.so 8.so and liblog. Some gotchas already found:   It draws text starting on a Y coordinate which represents the baseline. but not the bottom of strings like "qg". libc.so 10.2+ and in this API level the following libraries are supported by the NDK: 1.so 7. Native text drawing Native text drawing is a bit convoluted in Android and the documentation is quite bad too. which is the bottom of strings like "abc".

Why the caret of a TEdit keeps blinking after clicking on the form When clicking on the form the LCL focus will refuse to move from the Edit to the Form because this behavior seems to be hard coded in the LCL. override. although maybe we might change this for Android. Using the Native ListView Dialog To allow the user to select items from a list more easily we offer a routine which launch dialog with the native ListView. thus we have a focus mismatch. Android ComboBox For adding Android combobox support a new method was added to LCLIntf along with a global variable to store the callback of this dialog: var OnShowSelectItemDialogResult: TOnShowSelectItemDialogResult. the LCL refuses to do that and keeps its focus in the Edit. This method will run a native item selection dialog. function ShowSelectItemDialog(const AItems: TStrings): Boolean. This might eventually be fixed in the future. or result false without doing anything otherwise. So even while we set focus into the form. if the platform has one. {$ifdef LCLCustomDrawn} .

AColorOddRow: jint = $ff292C29. 'Title3'. ['Title1'. 'Descr6']). or -1 if the dialog was cancelled by the user. 'Descr3'.ShowListViewDialog('Dialog Title'. {$endif} procedure TForm2. CDWidgetSet. end. 'Title4'. 'Descr4'. 'Descr2'. don't use TColor here! procedure TCDWidgetSet. begin {$ifdef LCLCustomDrawn} LCLIntf. 'Title5'. 'Descr5'. procedure TForm2. which allow choosing the color for the odd and the other for the even rows. ADescriptions: array of string. 'Title2'.OnListViewDialogResult will be called with the selected item. {$endif} end.ShowListViewDialog(ATitle: string. LazDeviceAPIs .OnListViewDialogResult := @MyOnListViewDialogResult. AColorEvenRow: jint = $ff424542). ATitles. LCLIntf. with a zero-based index. 'Title6']. The color is an integer of 32-bits in the ARGB format.Button3Click(Sender: TObject). ['Descr1'. lclintf. begin DebugLn(Format('[MyOnListViewDialogResult] ASelectedItem=%d'. Note that there are 2 more parameters in the end of this routine with default values. One way to cancel the dialog is when the user pressed the back button.MyOnListViewDialogResult(ASelectedItem: Integer).uses customdrawnint. [ASelectedItem])).