LAMW App Crashes on Start up lazarus / 43-Android ---------------------------------------------------------------------- Warfley · 2016-07-22 14:12 Hey guys, i have a problem using LAMW to build and run an APK on an Android AVD. So basically what im doing is this: Create new LAMW project, NDK 11c, SDK version 21, architecture x86 (like my AVD) then i build the empty app and run it (with some controls, a button and an edit). Everything works perfectly well. Then i change something (in this particular case i added a location component). Try to build and run again, the app crashes with the messagebox "unfortunately the app has stopped". Then i undo the changes I made to the point it had run in first place, try to build and run again, still crashing with this error. These are some parts of the ADB log, i think might be about the problem (i'm not so much into android, just pressed ctrl+f and searched for error): QuoteI/DEBUG   ( 1131): pid: 2246, tid: 2246, name: lamwguiproject2  >>> org.lamw.lamwguiproject2 <<< I/DEBUG   ( 1131): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr -------- I/DEBUG   ( 1131): Abort message: 'art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallObjectMethodA called with pending exception 'java.lang.NoSuchMethodError' thrown in void org.lam w.lamwguiproject2.Controls.pAppOnCreate(android.content.Context, android.widget.RelativeLayout):-2' I/DEBUG   ( 1131):     eax 00000000  ebx 000008c6  ecx 000008c6  edx 00000006 I/DEBUG   ( 1131):     esi b779ff08  edi 0000000b I/DEBUG   ( 1131):     xcs 00000073  xds 0000007b  xes 0000007b  xfs 00000007  xss 0000007b I/DEBUG   ( 1131):     eip b770c456  ebp 000008c6  esp bf8a32f0  flags 00200282 I/DEBUG   ( 1131): I/DEBUG   ( 1131): backtrace: I/DEBUG   ( 1131):     #00 pc 00075456  /system/lib/libc.so (tgkill+22) I/DEBUG   ( 1131):     #01 pc 00021b1b  /system/lib/libc.so (pthread_kill+155) I/DEBUG   ( 1131):     #02 pc 00023394  /system/lib/libc.so (raise+36) I/DEBUG   ( 1131):     #03 pc 0001b874  /system/lib/libc.so (abort+84) I/DEBUG   ( 1131):     #04 pc 003735e6  /system/lib/libart.so (art::Runtime::Abort()+294) I/DEBUG   ( 1131):     #05 pc 000ec304  /system/lib/libart.so (art::LogMessage::~LogMessage()+1668) I/DEBUG   ( 1131):     #06 pc 00101598  /system/lib/libart.so (art::JniAbort(char const*, char const*)+1656) I/DEBUG   ( 1131):     #07 pc 00101ecc  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+108) I/DEBUG   ( 1131):     #08 pc 00107ffb  /system/lib/libart.so (art::ScopedCheck::CheckThread(int)+3147) I/DEBUG   ( 1131):     #09 pc 00108972  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+322) I/DEBUG   ( 1131):     #10 pc 0011455b  /system/lib/libart.so (art::CheckJNI::CallObjectMethodA(_JNIEnv*, _jobject*, _jmethodID*, jvalue*)+59) I/DEBUG   ( 1131):     #11 pc 00032e93  /data/app/org.lamw.lamwguiproject2-2/lib/x86/libcontrols.so I/DEBUG   ( 1131):     #12 pc 00040d48  /data/app/org.lamw.lamwguiproject2-2/lib/x86/libcontrols.so I/DEBUG   ( 1131):     #13 pc 0003aec4  /data/app/org.lamw.lamwguiproject2-2/lib/x86/libcontrols.so I/DEBUG   ( 1131):     #14 pc 000106d5  /data/app/org.lamw.lamwguiproject2-2/lib/x86/libcontrols.so I/DEBUG   ( 1131):     #15 pc 0006ad4b  /data/dalvik- cache/x86/data@app@org.lamw.lamwguiproject2-2@base.apk@classes.dex I/DEBUG   ( 1131): I/DEBUG   ( 1131): Tombstone written to: /data/tombstones/tombstone_06I/BootReceiver( 1470): Copying /data/tombstones/tombstone_06 to DropBox (SYSTEM_TOMBSTONE) E/SharedPreferencesImpl( 1470): Couldn't create directory for SharedPreferences file shared_prefs/log_files.xml I/Zygote  ( 1138): Process 2246 exited due to signal (6) W/libprocessgroup( 1470): failed to open /acct/uid_10056/pid_2246/cgroup.procs: No such file or directory I/ActivityManager( 1470): Process org.lamw.lamwguiproject2 (pid 2246) has died The whole log and the project is added as attachment to this post. What am i doing wrong? I have no Idea. ---------------------------------------------------------------------- jmpessoa · 2016-07-22 16:38 Hello Warfley! Please, try: 1. Close and re-open your project again ... 2. Check this path [project.lpi], it exists in your system? QuoteC:\Developer\Android\ndk\android- ndk-r11c\toolchains\x86-4.9\prebuilt\lib\gcc\i686-android-linux\4.9\ 3. Doing a new project the problem continue? 4. Check your AVD CPU/ABI ...... [my is ARM, so I dont get to test for x86!] EDITED: here in "project.lpi" we can note that the path C:\Developer\Android\ndk\android- ndk-r11c\toolchains\x86-4.9\prebuilt\\bin is incomplete .... after prebuild "windows" was missing... ---------------------------------------------------------------------- Warfley · 2016-07-22 22:58 Thank you for your quick answer. I don't know how the part of this path got lost (i haven't changed anything) i will try it when i am back home. But i had the same issue with some other projects, it works once and then no more, and i haven't changed anything on the path, could this be a bug? And second of all, currently im not at home, but i tried to run lamw on my macbook. As it works fine with Linux, and the Crosscompilers, ndk, sdk and ant are working fine with OS X, so i thought ill give it a trail. But i found a huge problem with it, i could install the packages, but when i try to enter the path config window (Tools->[LAMW] ... -> ...), it crashes. Is there any possibility to fill the data by hand (in a config file or something)? I'd like to check out if it works with OS X too. Edit: Solved the OS X problem by replacing the RadioGroup with a Combobox. But with OS X it also cut's the Path off (New Project -> JNI GUI, then Project Settings->Paths the i386-darwin is missing), so it seems that this might be a bug within LAMW ---------------------------------------------------------------------- jmpessoa · 2016-07-23 01:35 Hi Warfley! 1. You can get the config file "JNIAndroidProject.ini"  in "Lazarus\config\" folder... 2. Please, on  windows,  try  an "ARM" project , so we can see if  it also cut the project path ...  [LAMW BUG?] ---------------------------------------------------------------------- Warfley · 2016-07-25 11:59 So first of all, im back on my windows PC, and tried to fix the Path, it worked fine (for now). But the path gets also cut of with an armv6 and armv7 + VFPv3 project ---------------------------------------------------------------------- jmpessoa · 2016-07-25 17:05 Hi Warfley, Please, put here your  "JNIAndroidProject.ini"  from  "Lazarus\config\" folder... ---------------------------------------------------------------------- Warfley · 2016-07-25 23:30 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i [NewProject]PathToNdkPlataforms=C:\Developer\Android\ndk\android-ndk- r11cPathToJavaTemplates=C:\Developer\Android\lazandroidmodulewizard\ja vaPathToJavaJDK=C:\Program Files\Java\jdk1.8.0_101PathToAndroidNDK=C:\ Developer\Android\ndk\android-ndk- r11cPathToAndroidSDK=C:\Developer\Android\AndroidSDKPathToAntBin=C:\De veloper\Android\apache-ant- 1.9.7\binNDK=4PathToWorkspace=C:\Developer\Android\ProjectsFullProject Name=InstructionSet=0ProjectModel=1AntPackageName=org.lamwAndroidPlatf orm=6MinApi=8TargetApi=0AntBuildMode=debugMainActivity=AppSupportV4=ye sPrebuildOSYS=Well i guess its a problem that PrebuildOSYS is empty ---------------------------------------------------------------------- jmpessoa · 2016-07-26 00:56 Yes, PrebuildOSYS empty is a LAMW BUG [I will try fix it!]! Please, set  PrebuildOSYS  according to your system: PrebuildOSYS=windows or PrebuildOSYS=windows-x86_64 or PrebuildOSYS=linux-x86_32 or PrebuildOSYS=linux-x86_64 or PrebuildOSYS=darwin-x86_64 ---------------------------------------------------------------------- CC · 2017-09-18 21:33 Hi, LAMW looks very promising, great work! I wanted to see how the demos work, but there is a problem which occurs with even the simplest project. The app crashes right after starting. This is the relevant part of the logcat dump: W/PGMiddleWare( 3986): in handleAction, invoke client = com.huawei.pgmng.middleware.AudioEffectLowPowerImpl@1a140eae, action = com.huawei.pgmng.PGAction@260af53 actionId =10010 pkg =com.huawei.android.launcher extend1 =179 extend2 = flag =3 type =1 W/OpenGLRenderer( 4104): Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer... Versions : Windows 7 prof CodeTyphon 6.20 32bit FreePascal 3.1.1  Source 11-08-2017 SVN Rev 36870 LAMW latest git jre1.8.0_144 32bit jdk1.7.0_80 / jdk1.8.0_144 (tried with both) 32bit android-ndk-r10e-windows-x86 android-sdk  Target: 24,26 (tried with both)                    Min version: 15 apache-ant-1.10.1 Test device: Huawei p8 - android 5.01 LG Leon - android 5.01 Is it possible to debug a LAMW app? (The pascal part with Lazarus / Java Part with Eclipse?) Is there a downloadable APK known to be working I could use to test if this is something Device/Android version specific? ---------------------------------------------------------------------- jmpessoa · 2017-09-19 00:07 Hi,  CC Try: targetSdkVersion = 21 for Android 5.01 [Have you an "android" cross-compile installed?] ---------------------------------------------------------------------- CC · 2017-09-19 00:27 Hi, thank you for your answer. Unfortunately the problem remains the same. I have tried API 21 for the minimal version too  with the same result. API 15 as a target does not compile at all. Can you recommend the right versions to use for all parts involved?  JRE, JDK, Ant, NDK, SDK (Tools ,... )  ...  I have installed the Android cross elements. Does not seem to be any problem with building the SO.  PS: I understand that this is the Lazarus forum and the IDE I am using is fork of Lazarus, but the problem does not seem to be IDE related and this as the only place I can hope to find a solution. ---------------------------------------------------------------------- jmpessoa · 2017-09-19 00:31 QuoteCan you recommend the right versions to use for all parts involved... Your "parts" install is OK! But, about your "cross-compile"? ---------------------------------------------------------------------- CC · 2017-09-19 00:44 I am not sure how to test  if it is ok any other way than building the android app. There is a file the with the name  "win32-arm-android-readme.txt" in the FPC directory with this text: QuoteFiles in this directory are part of CodeTyphon Studio Toolchains Library. Build with CodeTyphon Center and GNU Binutils version 2.23.2 For Android NDK r8e GCC 4.7 Windows 32 bits I assume I should either use these versions, or an other  IDE and build the cross compiler. ---------------------------------------------------------------------- jmpessoa · 2017-09-19 01:01 Hi CC, Please, install  "Laz4android"  [Lazarus + "android-cross-compile" ] https://sourceforge.net/projects/laz4android/ choice a root directory like "C:\laz4android"  .... ---------------------------------------------------------------------- CC · 2017-09-19 01:42 This works out of the box. Thank you very much for your help! ---------------------------------------------------------------------- CC · 2017-09-19 12:50 One more thing: I need both LAMW and mORMot. The problem is that mORMot requires  up to date FPC and  the FPC in Laz4Android is rather old. I have installed Lazarus and FPC from trunk with  fpcupdeluxe, which is an other option to set up cross compilation easily. Is there a way this path could work? Currently the compilation fails.  Fatal: Cannot find system used by controls. Make sure all ppu files of a package are in its output directory. ppu in wrong directory=C:\fpcupdeluxe\fpc\units\arm-android\rtl\system.ppu.. The meaning of the error message is not quite clear to me, because  system.ppu does exists in C:\fpcupdeluxe\fpc\units\arm-android\rtl. I assume compiler options may have something to do with it. -Xd -CfSOFT -CpARMV6 / -CpARMV7A (tried both with clean up and build) -XParm-linux-androideabi- -FDC:\Android\ndk\\toolchains\arm-linux- androideabi-4.9\prebuilt\windows\bin It would be great to have a solution to use LAMW with up to date FPC. ---------------------------------------------------------------------- DonAlfredo · 2017-09-19 13:28 You're right: the mORMot does not run (yet) with Laz4Android. And the demo-projects  of LAMW are not suitable for the arm-cross- compiler that comes with fpcupdeluxe. At the moment, I am looking into this. Fpcupdeluxe must be able to work with LAMW ! So stay tuned. ---------------------------------------------------------------------- CC · 2017-09-19 14:20 DonAlfredo, great news, thanks! ---------------------------------------------------------------------- CC · 2017-09-20 08:58 jmpessoa There is a mORMot demo app, so I assume at one point mORMot did work with LAMW and Laz4Android.  I could check out  that version to do some tests. Can you remember the approximate  date of the version you used with the demo app? ---------------------------------------------------------------------- DonAlfredo · 2017-09-20 10:41 The mORMot demo app was made by me. And it worked very well when it was made. However, it definitely stopped working with recent versions of LAMW, FPC and Lazarus that are installed by fpcupdeluxe (eg the cross- compiler installed by fpcupdeluxe ! Current status: I have the app working again (setup with fpcupdeluxe). But any app I make (with or without mORMot) crashes as soon as the layout of the visual components is changed ! The same app (without mORMot) works 100% when compiled with Laz4Android. This is a strange error. Trying to solve. ---------------------------------------------------------------------- CC · 2017-09-20 11:41 DonAlfredo You are quick. Which repo  has your latest fixes for FPC/Lazarus/mORMot/Possibly LAMW? ---------------------------------------------------------------------- CC · 2017-09-20 14:07 I have tried quite a few revisions from the mORMot  git repo with Laz4Android.  It was possible to create the apk  from some of them, but they all crashed when the SqlModel was created. Maybe it is not working with the current version of  LAMW at all. ---------------------------------------------------------------------- jmpessoa · 2017-09-20 22:48 QuoteMaybe it is not working with the current version of  LAMW at all... No,  the question can be:  how [and what] fpc cross-compile you  need to target " mORMot" ... ---------------------------------------------------------------------- CC · 2017-09-21 09:02 Thanks for the clarification. ---------------------------------------------------------------------- DonAlfredo · 2017-09-21 15:56 Good news ! The link contains the LAMW mORMot-sample that works with latest fpcupdeluxe and latest LAMW. (at least on my system) A working debug-apk is included to show you how it should work ! The database will be created in the Android Download-directory for easy inspection. https://drive.google.com/file/d/0B96fg3TpL5RDMjZoZUlra1p3S0E/view?usp= sharing Please note that the mORMot only works with ARMV7 "hardfloat" VFPV3. This version is, by coincidence, also installed by fpcupdeluxe ... ;-) ---------------------------------------------------------------------- CC · 2017-09-21 18:41 Wow, we are so lucky to have you here. The work you did on mORMot to make it crossplatform is amazing. The APK seems to be  working. Which repos should I check out with fpcupdeluxe ? ---------------------------------------------------------------------- DonAlfredo · 2017-09-21 19:05 Just normal FPC/Lazarus trunk. Speedbutton left-below. ---------------------------------------------------------------------- CC · 2017-09-21 22:47 The development environment is up and running now. It is possible to compile your test project , but building the apk   fails. Panic: C:\A\Projects\DEMO\AppmORMotDemo1\build.xml:12: Cannot find C:\tools\ant\build.xml imported from C:\A\Projects\DEMO\AppmORMotDemo1\build.xml Maybe a path issue? It seems as if "C:\tools\" was somehow hard-coded. (It is installed to a different directory.) Creating an empty LAMW project works perfectly now. ---------------------------------------------------------------------- jmpessoa · 2017-09-21 23:05 Hi CC, Go to folder "lazarus\config" and  check  "JNIAndroidProject.ini" for "PathToAntBin=......." ---------------------------------------------------------------------- CC · 2017-09-21 23:12 It has the real path to ant. The problem does not occur with any other projects started from scratch, only with DonAlfredo's new mORMot  app. ---------------------------------------------------------------------- jmpessoa · 2017-09-21 23:16 And for others "demos" ?? ---------------------------------------------------------------------- CC · 2017-09-21 23:25 After changing custom options to -CfVFPV3 -CpARMV7A  AppDemo1 compiles and runs on the device as expected.  With new LAMW apps  there is something wrong with the positioning of  the controls. They are all at the top of a the form, partially covering each other.  Could be me missing some basic stuff. If this is not related to the compilation issues probably best discussed in a different topic. ---------------------------------------------------------------------- CC · 2017-09-21 23:29 2D graphics is crashing DemoApp1 though. But it was the same when it was compiled with Laz4Android, so again it is  a different topic. ---------------------------------------------------------------------- jmpessoa · 2017-09-21 23:42 QuotePanic: C:\A\Projects\DEMO\AppmORMotDemo1\build.xml:12: Cannot find C:\tools\ant\build.xml imported from C:\A\Projects\DEMO\AppmORMotDemo1\build.xml Maybe a path issue? It seems as if "C:\tools\" was somehow hard-coded. (It is installed to a different directory.) Your  problem is here: QuoteCannot find C:\tools\ant\build.xml                               This part "C:\tools\" should be replaced [by LAMW] to your "android- sdk" local path ---------------------------------------------------------------------- CC · 2017-09-21 23:49 My JNIAndroidProject.ini, all paths are valid. Is there any other place I could change the path? [NewProject] PathToAndroidSDK=C:\Android\sdk PathToAndroidNDK=C:\Android\ndk PathToNdkPlataforms=C:\Android\ndk PathToJavaTemplates=C:\fpcupdeluxe\ccr\lamw\java PathToJavaJDK=C:\Program Files (x86)\Java\jdk1.8.0_144 PathToAntBin=c:\Apps\apache-ant\bin NDK=3 PrebuildOSYS=windows PathToWorkspace=C:\A\Test FullProjectName=C:\A\Test\LamwGUIProject2 InstructionSet=2 ProjectModel=1 AntPackageName=org.lamw AndroidPlatform=0 MinApi=2 TargetApi=1 AntBuildMode=debug MainActivity=App SupportV4= ---------------------------------------------------------------------- jmpessoa · 2017-09-22 00:00 You can: 1.Test if you have "C:\Android\sdk\tools\ant\build.xml" 2. Check "AppmORMotDemo1\build.xml" for missing sdk path ... ---------------------------------------------------------------------- CC · 2017-09-22 00:29 jmpessoa  "AppmORMotDemo1\build.xml"  existed, but it its content was not right.  After replacing it with the original file from DonAlfredo LAMW works with  mORMot again. You were very helpful, thank you! ---------------------------------------------------------------------- CC · 2017-09-22 09:19 Summary: If anyone wants to use fpcupdeluxe with LAMW  check out the trunk versions. Project custom options needs to have these: -CfVFPV3 -CpARMV7A I have successfully compiled and executed LAMW demos with SDK API 21,25,26 with Min API 14. The mORMot demo needs to be updated in the LAMW repo @DonAlfredo: if you made  changes to mORMot source please let us know when it is commited to the mORMot repo. ---------------------------------------------------------------------- DonAlfredo · 2017-09-22 10:21 No changes were made regarding the mORMot source ! mORMot works out-of-the-box with FPC trunk. Also. No custom options are needed. If all goes well, all settings are already correct and used by FPC in fpc.cfg. E.g. -CfVFPV3 -CpARMV7A is set by fpc.cfg I will update the mORMot sample by doing a pull-request for LAMW. Please note that the setup as created by fpcupdeluxe can also be used to build Android-apps based on the very nice Castle Game Engine !! https://castle-engine.sourceforge.io/ The same is valid for the also very nice Platform eXtended Library ! http://asphyre.net/platformextendedlibrary ---------------------------------------------------------------------- CC · 2017-09-22 11:04 DonAlfredo Thanks for the clarification. Your suggestions may come handy. The way LAMW IDE tools is currently  implemented it will add some customn options ( -Cf -Cp included) when creating a new app. This is something to be mindful of. ---------------------------------------------------------------------- DonAlfredo · 2017-09-22 11:29 @CC You are very right ! Perhaps a WiKi entry should be added for users of LAMW that have used fpcupdeluxe to install trunk/cross-compilers, and want to create Android apps with FPC trunk (and mORMot). ---------------------------------------------------------------------- DonAlfredo · 2017-09-23 08:37 The mORMot demo has been updated in the LAMW repo. ---------------------------------------------------------------------- CC · 2017-09-23 21:08 Thank you!