Recent

Author Topic: [Solved] Lost with creating Android project structure  (Read 8725 times)

huberte

  • Jr. Member
  • **
  • Posts: 78
[Solved] Lost with creating Android project structure
« on: April 18, 2012, 03:43:13 am »
Hi,

Could it be possible to show me something more explicit than

http://wiki.lazarus.freepascal.org/Custom_Drawn_Interface/Android
Quote
Things to change are the path to the SDK, the package name. The package name needs to be updated in the build files, in the directory structure android/src/packagename, in the activity java source code and also in the main library pascal source in the exports section.

I'm quite lost.

thks.
« Last Edit: April 28, 2012, 10:09:03 pm by huberte »

huberte

  • Jr. Member
  • **
  • Posts: 78
Re: [Noob] Lost with creating Android project structure
« Reply #1 on: April 18, 2012, 09:06:18 pm »
Can someone explain me which file from androidlcl I have to modify, copy or paste to build my own app ? I'm using the vbox image.

http://pastebin.com/37WtWFSH

thanks.


huberte

  • Jr. Member
  • **
  • Posts: 78
Re: [Noob] Lost with creating Android project structure
« Reply #2 on: April 19, 2012, 02:29:35 am »
spent about 10 hours on this

I'm gonna make a first part :

Quote
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". This example can be obtained from the Lazarus source tree in lazarus/examples/androidlcl

done, but I don't know where the build and java files really are...

Quote
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

Library ? : http://wiki.lazarus.freepascal.org/shared_library ?

Quote
Then you will need to modify the build files to change them to your new project name and your new Java package name.

Lost

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: [Noob] Lost with creating Android project structure
« Reply #3 on: April 19, 2012, 09:44:23 am »
Quote
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". This example can be obtained from the Lazarus source tree in lazarus/examples/androidlcl

done, but I don't know where the build and java files really are...

The file structure of the example project looks like this:

lazarus/examples/androidlcl/*
lazarus/examples/androidlcl/android/*
lazarus/examples/androidlcl/android/src/com/pascal/lcltest/  <-- Here is the java source file

Note com/pascal/lcltest is the *package name* of the project. You need to decide your own package name. And then create your own structure:

myproject/ <- here copy everything from androidlcl/
myproject/android/src/com/mycompanyname/myprojectname/ <-- Here put the java source file

All changes need to be reflected in the ANT build files. Also open the java source file, I think you will need to change the package name there too. And you will also have to change the package name in the exported routine names in your main library file.

Quote
Library ? : http://wiki.lazarus.freepascal.org/shared_library ?

Yes

Quote
Then you will need to modify the build files to change them to your new project name and your new package name.

Open the directory lazarus/examples/androidlcl/android/

Now read *all* files directly inside this directly using a text editor. Note all the places which have paths, project names and package names.

huberte

  • Jr. Member
  • **
  • Posts: 78
Re: [Noob] Lost with creating Android project structure
« Reply #4 on: April 22, 2012, 12:50:57 am »
thanks

Quote
All changes need to be reflected in the ANT build files.

Where ?

Quote
And you will also have to change the package name in the exported routine names in your main library file.

Link ? Cause I have many many files in the example folder's root (androidlcltest (lpi, lpr lps) mainform non androidtest secondform)

Quote
Quote
Library ? : http://wiki.lazarus.freepascal.org/shared_library ?

Yes

Not helping further. I thought I could add this line 
Code: [Select]
library androidlcltest; to the top of my own project.

Quote
Open the directory lazarus/examples/androidlcl/android/
Now read *all* files directly inside this directly using a text editor. Note all the places which have paths, project names and package names.

Seems there is only build.sh unless I have to open ALL files in all folders.

For example, here are the file with LCLexample :
Quote
Search "LCLexample" (3 hits in 3 files)
 \android\.svn\text-base\build.sh.svn-base (1 hits)
   Line 3: ~/Programas/android-sdk-linux/platform-tools/adb install bin/LCLExample-debug.apk
  \android\.svn\text-base\build.xml.svn-base (1 hits)
   Line 2: <project name="LCLExample" default="help">
  \android\build.xml (1 hits)
   Line 2: <project name="LCLExample" default="help">

AndroidManifest needs to be update too, right ? How ? Using a texte editor ?

Step 3 is driving me crazy

Quote
Besides the LCL project building, such as configuring a proper LPI and having a library main project file, one also needs to add all of the android project structure. Simply copy from the example project in lazarus/examples/androidlcl and adapt it to the new project. Things to change are the path to the SDK, the package name. The package name needs to be updated in the build files, in the directory structure android/src/packagename, in the activity java source code and also in the main library pascal source in the exports section.
« Last Edit: April 22, 2012, 02:13:48 am by huberte »

huberte

  • Jr. Member
  • **
  • Posts: 78
Re: [Noob] Lost with creating Android project structure
« Reply #5 on: April 22, 2012, 04:50:37 am »
Ok Here am I:

Changed Project Nme in folder and files (see previous post)
Changed AndroidManifest with texteditor
I did verify build options (cf wiki). I think I miss something on step 3.

I end with a myproject-debug.apk (why debug by the way ?) but still with the two forms from the example (I did create two other form for testing, named the same way : mainform and secondform).

when this work is done I copy myproject folder into the vbox image and start ant debug

Like I said, I think I missed smthg, cause it seems that old entries are still there in : .svn\text-base\mainform.lfm.svn-base, lib\arm-linux\mainform.lfm (seems to be building files but how can I build ?)

thks again for your help
« Last Edit: April 22, 2012, 03:30:16 pm by huberte »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: [Noob] Lost with creating Android project structure
« Reply #6 on: April 22, 2012, 12:13:38 pm »
Quote
All changes need to be reflected in the ANT build files.
Where ?

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/examples/androidlcl/android/?root=lazarus

Quote
Link ? Cause I have many many files in the example folder's root (androidlcltest (lpi, lpr lps) mainform non androidtest secondform)

The main projet file for Android. Might be lpr or pas. In the example project it is this one:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/examples/androidlcl/androidlcltest.lpr?view=markup&root=lazarus

Quote
Not helping further. I thought I could add this line 
Code: [Select]
library androidlcltest; to the top of my own project.

You should have 2 separate LPI files each with a separate LPR main program file, one for Android and for non-Android.

Quote
Seems there is only build.sh unless I have to open ALL files in all folders.

For example, here are the file with LCLexample :
Search "LCLexample" (3 hits in 3 files)
 \android\.svn\text-base\build.sh.svn-base (1 hits)
   Line 3: ~/Programas/android-sdk-linux/platform-tools/adb install bin/LCLExample-debug.apk
  \android\.svn\text-base\build.xml.svn-base (1 hits)
   Line 2: <project name="LCLExample" default="help">
  \android\build.xml (1 hits)
   Line 2: <project name="LCLExample" default="help">

Search? Which search are you talking about? There is the proper list of files:

http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/examples/androidlcl/android/?root=lazarus

As you can see there are many files. Not only build.xml

The .svn folder should be always ignored. It is Subversion internal files. You should delete the .svn folder in your project if you are making a copy of this folder from lazarus.

Quote
AndroidManifest needs to be update too, right ? How ? Using a texte editor ?

Yes, use any plain text editor. Lazarus also works as a text editor for example.

I end with a myproject-debug.apk (why debug by the way ?)

Because it is signed with a debug key intended for development. For proper distribution in the Android market you need a release signing process.

Quote
when this work is done I copy myproject folder into the vbox image and start ant debug

And what happens then? It works?
« Last Edit: April 22, 2012, 12:16:39 pm by felipemdc »

huberte

  • Jr. Member
  • **
  • Posts: 78
Re: [Noob] Lost with creating Android project structure
« Reply #7 on: April 22, 2012, 03:33:40 pm »
Quote
Quote
when this work is done I copy myproject folder into the vbox image and start ant debug

And what happens then? It works?

Sorry, I was not  so clear. No, I still end up with the two old forms (in the apk) from the example while I changed those two forms (lfm, pas files). Do I miss something, do I need to build something before the apk ?

It's very confusing

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: [Noob] Lost with creating Android project structure
« Reply #8 on: April 22, 2012, 07:08:56 pm »
Sorry, I was not  so clear. No, I still end up with the two old forms (in the apk) from the example while I changed those two forms (lfm, pas files). Do I miss something, do I need to build something before the apk ?

Yes, you need to build the library (your project) in Lazarus before building the APK. The project should be configured to automatically place the compile library in android/libs/armeabi/ like the example does. You can delete older .so file to make sure you are creating a new one. If you change the name of the library then you need to reflect that in other places. I don't remember where exactly, I think that in android/src/com/pascal/projectname/something.java somewhere there in the end is the name of the library to load.
« Last Edit: April 22, 2012, 07:13:05 pm by felipemdc »

 

TinyPortal © 2005-2018