Difference between revisions of "Android Interface"

From Free Pascal wiki
Jump to navigationJump to search
(redirect)
 
(35 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== Architecture ==
+
#REDIRECT [[Custom Drawn Interface/Android]]
 
 
As of August 2010 (and Android 2.2), the Android platform can only execute Java Android applications, but these applications can load native libraries and can also run native executables. Therefore, to create Pascal applications in Android one can use one of these methods:
 
 
 
*method 1> Write the Pascal application as a library connected to the Java application via JNI
 
*method 2> Write the Pascal application as an executable and connect it to Java via pipes or sockets
 
 
 
Running the LCL application as a library and communicating with Java via JNI to create a native interface would generate several serious issues:
 
#The main project file would need to be different for Android apps
 
#Free Pascal has some issues with DLLs
 
#The Java Native Interface is very complex and very hard to work with. Worse even that it is totally geared to C++ and is very limited.
 
 
 
To avoid these issues it was preferred to create instead a native executable for the Lazarus applications and let it communicate with the auxiliary Java application only for indispensable things.
 
 
 
On top of that, for both solutions there would be two basic GUI solutions possible. Because both are attractive, at the moment both are being worked on and in the future probably one of them will prove itself the best solution:
 
 
 
* [[Android Interface/Native Android GUI]]
 
** This has the solution of being faster to develop
 
** The bad side is that a native android widgetset will be completely specific to Android, and therefore its work will be lost in the event that the Android platform goes through serious changes or if Android becomes irrelevant in the market.
 
** Lower graphics drawing performance
 
* [[Android Interface/OpenGL ES GUI]]
 
** Longer lasting solution, but takes much longer to develop and getting it stable
 
** Not as well integrated in the system
 
** Higher graphics drawing performance
 
 
 
== Roadmap ==
 
 
 
# Build the set of [[Lazarus Custom Drawn Controls]]
 
# Learn how to write simple FPC apps which use OpenGL in Android
 
# Implement the basic Java Android encapsulating application
 
# Extend the Java app to expose Android APIs
 
# Write the new customdrawn base widgetset
 
# Write the new opengl base widgetset
 
# Write the new android widgetset
 
 
 
==Using the Android SDK, Emulator and Phones==
 
 
 
[[Android Interface/Using the Android SDK, Emulator and Phones]]
 
 
 
==Android Programming==
 
 
 
[[Android Interface/Android Programming]]
 
 
 
==Configuring the Free Pascal Compiler for Android==
 
 
 
===Building the compiler yourself===
 
 
 
[[Setup_Cross_Compile_For_ARM]]
 
 
 
===Using the pre-compiled compiler===
 
 
 
A pre-compiled compiler is provided for convenience for users. The following steps were tested in Mandriva Linux 2010.0 and 2010.1:
 
 
 
'''Required Environment'''
 
 
 
* A standard FPC 2.4.2 installed in the system via the RPM package
 
 
 
'''Step 1''' - Install the cross-binutils
 
 
 
For Mandriva Linux the RPM package containing arm-linux-as, arm-linux-ld, etc, which are the cross-binutils can be found here: http://rpm.pbone.net/index.php3/stat/4/idpl/14252825/dir/mandriva_2010/com/cross-arm-binutils-2.20.51.0.4-2mnb2.i586.rpm.html
 
 
 
Just download the RPM package and install it using: fpc -ivh cross-arm-binutils-2.20.51.0.4-2mnb2.i586.rpm
 
 
 
In Mandriva Linux 2010.0 the dependencies won't match, as the package is for 2010.1, but one can simply ignore this problem and it works fine using --nodeps:
 
 
 
[root@localhost Programas]# rpm -ivh --nodeps cross-arm-binutils-2.20.51.0.4-2mnb2.i586.rpm
 
 
 
For other distributions use the corresponding package, or else read the instructions for building the cross-binutils yourself at [[Setup_Cross_Compile_For_ARM]]
 
 
 
'''Step 2''' - Configure the cross-binutils
 
 
 
The assembler needs a parameter to tell it which ARM ABI to use. A choice which works good is EABI-5, which is compatible with all Android devices available as of Jan 2011. To set this, we will rename the original assembler and substitute it with a shell script which passes the desired parameter. 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:
 
 
 
#!/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''' - Install Free Pascal
 
 
 
These commands will install the pre-compiled Free Pascal cross-compiler into /usr:
 
 
 
[felipe@localhost Programas]$ ls -l
 
total 20664
 
-rw-rw-r--  1 felipe felipe 17098552 2010-10-25 08:17 fpc-2.5.1.arm-linux.tar.gz
 
[felipe@localhost Programas]$ su
 
Password:
 
[root@localhost Programas]# cp fpc-2.5.1.arm-linux.tar.gz /usr/
 
[root@localhost Programas]# cd /usr/
 
[root@localhost usr]# tar -xvf fpc-2.5.1.arm-linux.tar.gz
 
[root@localhost usr]# ln -s lib/fpc/2.5.1/ppcrossarm bin/ppcrossarm
 
 
 
Now we are ready to compile Android applications using the Lazarus IDE! Configuring the fpc.cfg file isn't necessary, the compiled will automatically find the new compiler and it's object files.
 

Latest revision as of 06:48, 18 April 2012