Android on Lazarus lazarus / 43-Android ---------------------------------------------------------------------- mbdev · 2013-03-20 20:35 Hello, I want to develop Android apps with my Lazarus. I'm usining Lazarus v.1.0.8 and Freepascal 2.6.2. I tried to make a simple Android app, but it crashs with the error: C:\lazarus\fpc\2.6.2\bin\i386-win32\arm-linux-ld.exe: warning: link.res contains output sections; did you forget -T? C:\lazarus\fpc\2.6.2\bin\i386-win32\arm-linux-ld.exe: C:\Android\ndk-r8d\platforms\android-9\arch- arm\usr\lib\/libjnigraphics.so: Unknown mandatory EABI object attribute 44 C:\lazarus\fpc\2.6.2\bin\i386-win32\arm-linux-ld.exe: failed to merge target specific data of file C:\Android\ndk-r8d\platforms\android-9\arch- arm\usr\lib\/libjnigraphics.so I'm not sure what I did wrong, because I also added "-dAndroid" in the LCLBase (See Screenshot) ---------------------------------------------------------------------- Leledumbo · 2013-03-20 22:27 I don't you can do it with FPC 2.6.2, you'll need quite new trunk (2.7.1 no more than a week ago) or the old hacked 2.5.1. Please read the wiki instruction regarding Android. Here if you use 2.7.1. ---------------------------------------------------------------------- mbdev · 2013-03-27 17:27 Hi, I prepared it with FPC 2.7.1 but I'm getting the same error :/ Could it be that something is wrong with my android NDK? ---------------------------------------------------------------------- mbdev · 2013-03-27 17:58 I fixed it  It was wrong that I used the NDK8C and I just changed to the NDK7C ---------------------------------------------------------------------- mbdev · 2013-03-27 20:55 I've got another question. Where I need to put my compiled application when I want to generate the apk-file. The script (generate_debug_apk.bat): Code: [Select]REM Adjust these paths to yours SET PATH=C:\Android\sdk-20130219\sdk\tools;C:\Android\sdk- 20130219\sdk\platform-tools\;C:\Program Files\Java\jdk1.6.0_43\bin SET APP_NAME=Testapp SET ANDROID_HOME=C:\Android\sdk-20130219\sdk SET APK_SDK_PLATFORM=C:\Android\sdk-20130219\sdk\platforms\android-8 SET APK_PROJECT_PATH=C:\Users\Administrator\Desktop\Project\Testapp\an droid 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 DX to convert the java bytecode to dalvik bytecode call dx --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 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 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 senhas -storepass senhas -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 ---------------------------------------------------------------------- felipemdc · 2013-03-28 09:21 The shared object should be placed in lib\armeabi\ ---------------------------------------------------------------------- mbdev · 2013-03-28 11:33 Hm, I put my compile app in the lib\armeabi\ folder and renamed it to Testapp.so. Now my application is bigger, but it crashs at startup  Hopefully somebody can help me, I also uploaded my project (without android folder). Here are my scripts: build_debug_apk.bat Code: [Select]REM Adjust these paths to yours SET PATH=C:\Android\sdk-20130219\sdk\tools;C:\Android\sdk- 20130219\sdk\platform-tools\;C:\Program Files\Java\jdk1.6.0_43\bin SET APP_NAME=Testapp SET ANDROID_HOME=C:\Android\sdk-20130219\sdk SET APK_SDK_PLATFORM=C:\Android\sdk-20130219\sdk\platforms\android-8 SET APK_PROJECT_PATH=C:\Users\Administrator\Desktop\Project\Testapp\an droid 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 DX to convert the java bytecode to dalvik bytecode call dx --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 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 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 senhas -storepass senhas -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 generate_debug_key.bat Code: [Select]REM Adjust these paths to yours SET PATH=C:\Android\sdk-20130219\sdk\tools;C:\Android\sdk- 20130219\sdk\platform-tools\;C:\Program Files\Java\jdk1.6.0_43\bin SET APP_NAME=Testapp SET ANDROID_HOME=C:\Android\sdk-20130219\sdk SET APK_SDK_PLATFORM=C:\Android\sdk-20130219\sdk\platforms\android-8 SET APK_PROJECT_PATH=C:\Users\Administrator\Desktop\Project\Testapp\an droid mkdir bin keytool --help keytool -genkey -v -keystore bin\LCLDebugKey.keystore -alias LCLDebugKey -keyalg RSA -validity 10000 REM call and pause together allow us to see the results in the end pause I don't understand what I have to do with my compiled linux-arm app? ---------------------------------------------------------------------- felipemdc · 2013-03-28 12:30 Quote from: mbdev on March 28, 2013, 12:33:11 pmI put my compile app in the lib\armeabi\ folder and renamed it to Testapp.so. Now my application is bigger, but it crashs at startup  What was the name before you renamed it? It should already have been the proper name. Study the example application that comes with Lazarus. Android native applications are not executables, they are libraries, and they need to export a set of functions with the proper name refleting the package name of the application. ---------------------------------------------------------------------- mbdev · 2013-03-28 14:02 It was just named Testapp without a file extension  Like here: http://www.pilotlogic.com/sitejoom/index.php/codetyphon/codetyphon- help (last picture on 10.2.3) ---------------------------------------------------------------------- felipemdc · 2013-03-28 15:17 Does your project main source file start with "program"? If it does, then it is wrong, it should be "library". Study the example. ---------------------------------------------------------------------- mbdev · 2013-03-28 18:44 THANK YOU SO MUCH  It was a program. Now my app runs fine and I can understand why You helped me a lot