You are on page 1of 11

10.Sept.

2013

Lazarus and Android


After it took me xx weeks to get a working Android application with Lazarus, it is time to write a little tutorial. I am new to all this stuff and happy for the moment to get it working. But it in the future this must become less complicated. I have put my questions at the end of the document. To create Android Apps with Lazarus (on windows), you need to download and install the following packages. (Warning, this will take at least 4GByte of you diskspace) JDK 1.6u45 --> you will need to open a account at oracle to download older versions. (it's not nice but at least for free) http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase 6-419409.html#jdk-6u45-oth-JPR The setup does not allow to determ a installation path. It will be installed in to C:\Program Files\Java\. The following packages I put into one folder. In my case it is E:\android Android SDK http://dl.google.com/android/installer_r22.0.5-windows.exe Android NDK http://dl.google.com/android/ndk/android-ndk-r7c-windows.zip laz4android http://sdrv.ms/12cHbIZ laztoapk https://dl.dropboxusercontent.com/u/3753548/laztoapk_exe_alpha_0_12.7z After installation, it look's for example like this. the folder projects I created manually.

Now we need to prepare laz4android. Edit the file laz4android\build.bat and set the correct path.

Save the file and execute it. It will compile&bulid lazarus. When finished, start lazarus.exe and select Package Install/Uninstall Packages

Now double-click on customdraw and then click on button save and rebuild IDE.

Now close the IDE. Let's start the SDK Manager. (or directly from E:\android\sdk\SDK Manager.exe)

My installation looks like this. (sorry, no idea what's really needed)

After that, you need to setup a virtual android device. Let's start the AVD Manager. (or directly from E:\android\sdk\AVD Manager.exe)

After setup, press button <Start> to start the virtual Android Device. Yeesss, its very slowwww. (JAVA??) Wait,wait and then it should look like this:

Now it's time to start laztoapk.

When you start laztoapk the first time, a search-dialog will show up and you need to setup the directories/file for sdk ndk jdk 1.6 lazbuild.exe The search dialog works like this: a.) select the initial folder. (search will start from here) b.) press button Find. c.) select the item in the list and double-click onto to continue. For sdk it looks for example like this:

For ndk it looks for example like this:

For jdk it looks for example like this:

For lazbuild.exe it looks for example like this:

After all 4 items are setup, the main screen of laztoapk will be shown.

Press button for Step 1.

Select the folder projects and press button Create new folder.

Create a new folder project1, select the new folder and press button <OK>.

In the following dialog, define a password for your app and press button <OK>.

Now execute Step 2.

The project will be compiled&linked. The command window will look something like this:

Now execute Step 3.

You have to enter the same password as before twice in the command windows

and do some more input as requested. Now execute Step 4.

This will build the final apk-file and should look something like this:

Now the final step Step 5 to install the apk into the running android device. Make sure you have selected Emulator and your virtual android device is up an running.

Select the file <project1.apk> from the bin-folder and press button <Open>.

If everything works as expected, it should look like this:

Well done, the app is now installed.

Let's run the app. Click at the top right as displayed here.

Then click on project1.

And enjoy your first android application.

Questions
1. 2. 3. 4. Why do we need JDK installed? Why does it only work with JDK 1.6 but not with JDK 1.7? Which packages must really be installed in the SDK Manager? What could be removed so we do not need 4 Gbyte diskspace?

You might also like