Recent

Author Topic: Lazarus on Windows for Android  (Read 29286 times)

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #15 on: August 25, 2013, 12:44:03 pm »
I replied a while ago but it doesn't seem to have registered on the forum.
I have overcome the fcllaz/FCL problem by changing the environment.
Now I get a problem with "Unknown mandatory EABI object attribute 44" on linking the project.
mbdev received a similar message and overcame it by using NDK7C instead of NDK8C.
I am using ndk-r9. Does it mean I need to change it to a different ndk? If so, why?
Will I need to change ndk for different projects, or is it a question of stability?
I kave updated the sdk which included an "ARM EABI v7a System Image" installation, but that doesn't seem to make a difference.
Which version of NDK and SDK did you use to successfully compile the project?
Regards

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: Lazarus on Windows for Android
« Reply #16 on: August 25, 2013, 04:07:07 pm »
Hello polypress.I use Android NDK r7.
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #17 on: August 25, 2013, 05:55:45 pm »
Hello truetom
Yes. I've converted to ndk 7 (very limited availability - almost everything refers to ndk 9) and I've generated liblclapp.so but I can't convert it to .apk. I've edited generate_debug_key.bat and build_debug_apk.bat and run both but on searching the directories, there's no sign of liblclapp.apk. The DOS windows flash through so rapidly that you can't see what's happening and if there are any errors.
Any clues?
Regards

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #18 on: August 25, 2013, 06:22:47 pm »
I've slowed down the build_debug_apk.bat by piping it to a text file and examining the results:-
Could not find c:\laz4android\examples\androidlcl\android\bin\androidlcltest.ap_
Could not find c:\laz4android\examples\androidlcl\android\bin\androidlcltest.apk
aapt is not recognized as an internal or external command
Could not find c:\laz4android\examples\androidlcl\android\bin\androidlcltest-unsigned.apk
apkbuilder is not recognized as an internal or external command
unable to open bin\androidlcltest-unsigned.apk as zip archive.
As far as I can tell all paths are OK so what's wrong?
Regards

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: Lazarus on Windows for Android
« Reply #19 on: August 26, 2013, 03:36:09 am »
Hello polypress.
This is my build_debug_apk.bat file:
Code: [Select]
REM Adjust these paths to yours
SET PATH=C:\Progra~1\Android\android-sdk\tools;C:\Progra~1\Android\android-sdk\platform-tools\;C:\Progra~1\Java\jdk1.6.0_30\bin
SET APP_NAME=androidlcltest
SET ANDROID_HOME=C:\Progra~1\Android\android-sdk
SET APK_SDK_PLATFORM=C:\Progra~1\Android\android-sdk\platforms\android-8
SET APK_PROJECT_PATH=F:\laz4android\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 Cleanup
del bin\%APP_NAME%.ap_
del bin\%APP_NAME%.apk
del raw\lib\armeabi\*.so

REM More directory preparation
copy libs\armeabi\*.so raw\lib\armeabi\

REM Resource compilation
call aapt p -v -f -M AndroidManifest.xml -F bin\%APP_NAME%.ap_ -I %APK_SDK_PLATFORM%\android.jar -S res -m -J gen raw

REM Java compiler
call javac -verbose -encoding UTF8 -classpath %APK_SDK_PLATFORM%\android.jar -d bin\classes src\com\pascal\lcltest\LCLActivity.java

REM Convert the java bytecode to dalvik bytecode
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

REM It seams that dx calls echo off
@echo on
REM Now build the unsigned APK
del %APK_PROJECT_PATH%\bin\%APP_NAME%-unsigned.apk
call java -classpath %ANDROID_HOME%\tools\lib\sdklib.jar com.android.sdklib.build.ApkBuilderMain %APK_PROJECT_PATH%\bin\%APP_NAME%-unsigned.apk -v -u -z %APK_PROJECT_PATH%\bin\%APP_NAME%.ap_ -f %APK_PROJECT_PATH%\bin\classes.dex

REM Generating on the fly a debug key
rem keytool -genkey -v -keystore bin\LCLDebugKey.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.apk
jarsigner -verbose -keystore bin\LCLDebugKey.keystore -keypass 123456 -storepass 123456 -signedjar bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%-unsigned.apk LCLDebugKey

REM Align the final APK package
zipalign -v 4 bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%.apk

REM call and pause together allow us to see the results in the end
pause

In this batch file, as you saw , my batch file is not called apkbuilder.bat and dx.bat.
So it can used to any version of Andrid SDK .
« Last Edit: August 26, 2013, 06:34:04 am by truetom »
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

zariq

  • Full Member
  • ***
  • Posts: 107
Re: Lazarus on Windows for Android
« Reply #20 on: August 26, 2013, 04:11:43 am »
It's complaining about a missing apkbuilder. There was a discussion some months ago about newer sdk's not having apkbuilder. Could be your paths are are wrong, or are referring to old paths if you haven't removed it. It can't find aapt  either, which is in android-sdk\platform-tools, so probably wrong paths.

Regarding the window closing, put a pause at the end of the batch file.

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #21 on: August 26, 2013, 11:47:12 am »
I seem to have lost my latest post again, so here it is, again:-

Hello truetom
I can't find any reference to apkbuilder.bat or dx.bat in your code or mine, unless that is in the "call apkbuilder' script.
A major difference is :-
Mine:-
call apkbuilder %APK_PROJECT_PATH%\bin\%APP_NAME%-unsigned.apk -v -u -z %APK_PROJECT_PATH%\bin\%APP_NAME%.ap_ -f %APK_PROJECT_PATH%\bin\classes.dex

Yours:-
call java -classpath %ANDROID_HOME%\tools\lib\sdklib.jar com.android.sdklib.build.ApkBuilderMain %APK_PROJECT_PATH%\bin\%APP_NAME%-unsigned.apk -v -u -z %APK_PROJECT_PATH%\bin\%APP_NAME%.ap_ -f %APK_PROJECT_PATH%\bin\classes.dex

Perhaps this is what you mean.

Another difference is:-
Mine:-
SET APK_SDK_PLATFORM=C:\Android\sdk\platforms\android-18

jdk1.6.0_45

Yours:-
SET APK_SDK_PLATFORM=C:\Android\sdk\platforms\android-8

jdk1.6.0_30

When downloading the sdk it only had -18, not -8, although it uses -8 in ndk platforms. They don't have the same folders in them so I assume this doesn't cause any errors. ndk r7 only goes up to android-14, so I standardized on -8 throughout (except sdk platform of course - that only had android-18). I use the latest jdk (perhaps this is a mistake!?).

Using your code I can now get androidlcltest-unsigned.apk but not androidlcltest.apk (but I don't really understand why). Is this right, or am I still missing something?
On examining the command prompt window in more detail, it says it can't find androidlcltest-unaligned.apk (and aapt is not internal or external command, still).

Hello zariq
Changing the line of code above has overcome one problem, but I can't find any file aapt.* in the sdk platform-tools folder or anywhere within the sdk (I've renamed the folder from android-sdk to sdk for a shorter path - I hope this doesn't upset anything). It also says:-
Could not find [path]androidlcltest.ap_ and [path]androidlcltest.apk but I thought it is the purpose of this batch file to build such a file. This is very strange,

Regards to both

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #22 on: August 26, 2013, 12:36:06 pm »
Good News.
I've found aapt.exe in buid-tools of the sdk.
Including this in the path of build_debug_apk.bat gets me further.
Now it generates androidlcltest.ap_ but not androidlcltest.apk

Thank you both.

I'm nearer, but not there yet!

truetom

  • Jr. Member
  • **
  • Posts: 72
    • http://sourceforge.net/projects/laz4android/
Re: Lazarus on Windows for Android
« Reply #23 on: August 26, 2013, 02:22:33 pm »
Hello polypress.
Quote
Perhaps this is what you mean.
Yes , it's my mean.
Quote
jdk1.6.0_45

Yours:-
SET APK_SDK_PLATFORM=C:\Android\sdk\platforms\android-8

jdk1.6.0_30
JDK is not question.

Quote
Using your code I can now get androidlcltest-unsigned.apk but not androidlcltest.apk (but I don't really understand why). Is this right, or am I still missing something?
androidlcltest-unsigned.apk is a not sign apk file.you can sign it by yourself.this command:
jarsigner -verbose -keystore bin\LCLDebugKey.keystore -keypass [password,etc 123456]  -storepass [password,etc 123456] -signedjar bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%-unsigned.apk LCLDebugKey

androidlcltest-unaligned.apk is a not align apk file,this command:
zipalign -v 4 bin\%APP_NAME%-unaligned.apk bin\%APP_NAME%.apk

Of course after sign the apk,you also don't must align the apk, it's already can install to android device.
laz4android : a Lazarus for Android Package.
http://sourceforge.net/projects/laz4android/

zariq

  • Full Member
  • ***
  • Posts: 107
Re: Lazarus on Windows for Android
« Reply #24 on: August 26, 2013, 04:35:49 pm »
Before building use generate_debug_key.bat. where it asks for password enter senhas unless you have changed it in build_debug_apk.bat. If it says wrong key or something then delete the bin folder, generate the key and then build. If you were to post the contents of the two bat files and your paths, maybe somebody might spot something.

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #25 on: August 26, 2013, 04:39:10 pm »
Eureka!
It works.
Androidlcltest.apk copied to android phone and is working well, including the GPS position part.
Now I have to see how to convert old wm6.5 apps for this.

Thank you all.

Regards

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #26 on: August 28, 2013, 04:18:39 pm »
Hello All
Back again.
androidlcltest works well on the android phone, so I've been converting other wm6.5 applications for use on the same phone. Icompiles and transfers to the phone OK, but it will not run :-
"Unfortunately, [app] has stopped.". I assumed this was due to the [app]Activity.java file being incorrect, so I've gone all through it with JBuilder but I can't see the reason. Do you have a blank java activity file that I can work on. For the first app all I need to display are 6 edit boxes, 2 buttons and some floating point calculations. I don't know if there is too much resource in my java file for the requirements of the app.

Regards

Leledumbo

  • Hero Member
  • *****
  • Posts: 8111
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazarus on Windows for Android
« Reply #27 on: August 28, 2013, 04:42:50 pm »
Quote
Icompiles and transfers to the phone OK, but it will not run :-
"Unfortunately, [app] has stopped."
adb logcat output please...

polypress

  • Jr. Member
  • **
  • Posts: 91
Re: Lazarus on Windows for Android
« Reply #28 on: August 28, 2013, 05:27:06 pm »
Hi
I've tried adb logcat output [app].apk from the sdk platform-tools folder but it's just waiting for device and waiting and waiting...
Perhaps I haven't got everything installed.
Do I need an extra package?
Regards

Leledumbo

  • Hero Member
  • *****
  • Posts: 8111
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Lazarus on Windows for Android
« Reply #29 on: August 29, 2013, 05:57:04 pm »
Quote
I've tried adb logcat output [app].apk from the sdk platform-tools folder but it's just waiting for device and waiting and waiting...
Perhaps I haven't got everything installed.
Do I need an extra package?
I don't think so, but have you enabled USB debugging on the device?