Lazarus

Programming => Operating Systems => Android => Topic started by: schumi on June 07, 2021, 09:42:59 am

Title: [SOLVED] App Crash after update lazarus + LAMW
Post by: schumi on June 07, 2021, 09:42:59 am
Hi,
I have update lazarus + LAMW with FpCupDeluxe 1.8.2t 32bit with the new function [Android LAMW], now all app crash when a second form (also lamw demo app)

someone have same problem?

thanks
Title: Re: App Crash after update lazarus + LAMW
Post by: WayneSherman on June 07, 2021, 10:19:23 pm
now app crash when a second form (also lamw demo app)
someone have same problem?

Yes, I can confirm.  I just did a test build with AppDemo1 and it crashes when I press any of the buttons which open another form.

(I had to tweak some of the code and project options to get it to compile without errors)

Test environment:
Xubuntu 20.04 64-bit
installed using FPCUPdeluxe ver 1.8.2u
FPC stable v3.2.2
Lazarus stable v2.0.12
LAMW git from 2021-Jun-05

Android Command-Line Tools build 7302050
OpenJDK 11
Android SDK/API Level 29 (Android 10)
Android NDK revision 22
Gradle 6.8.3 (installed automatically by FPCUPdeluxe)

64-bit CPU Target: Aarch64
Target SDK 29

Tested on Google Pixel 4 (Android 11)
Title: Re: App Crash after update lazarus + LAMW
Post by: Mongkey on June 08, 2021, 12:37:04 pm
Maybe you can try create another form at main activity on creating activity, dont do create on onshow or on jniprompt. This one works for me. The last versio,n More smooth and lighter i think.
Title: Re: App Crash after update lazarus + LAMW
Post by: schumi on June 08, 2021, 01:59:44 pm
I use this code in a button to open form, I have 4 form in my app

Code: Pascal  [Select][+][-]
  1. if(AndroidModule2 = nil) then
  2.   begin
  3.       gApp.CreateForm(TAndroidModule2, AndroidModule2);
  4.  
  5.       AndroidModule2.InitShowing(gApp); <-- crash here
  6.   end
  7.   else
  8.   begin
  9.     AndroidModule2.Show;
  10.   end;
  11.  
Title: Re: App Crash after update lazarus + LAMW
Post by: Mongkey on June 08, 2021, 02:41:44 pm
Put all creating forms on, oncreate activity on main activity form. Dont put under button click, onshow, onjniprompt, it used to work, but not anymore -> You got new androidx  :D
Title: Re: App Crash after update lazarus + LAMW
Post by: schumi on June 08, 2021, 04:31:16 pm
Quote
Put all creating forms on, oncreate activity on main activity form. Dont put under button click, onshow, onjniprompt, it used to work, but not anymore -> You got new androidx 

how to switch to second form ? AndroidModule2.Show; dosn't work

thanks
Title: Re: App Crash after update lazarus + LAMW
Post by: WayneSherman on June 08, 2021, 04:58:42 pm
I have update lazarus + LAMW with FpCupDeluxe 1.8.2t 32bit with the new function [Android LAMW], now all app crash when a second form (also lamw demo app)
someone have same problem?

I recommend opening a bug report so this issue can be tracked:
https://github.com/jmpessoa/lazandroidmodulewizard/issues
Title: Re: App Crash after update lazarus + LAMW
Post by: DonAlfredo on June 08, 2021, 05:05:30 pm
Confirmed. Its caused by LAMW itself. This will be hard to solve due to the many changes that were made the last couple of weeks. Will look into.
Title: Re: App Crash after update lazarus + LAMW
Post by: schumi on June 08, 2021, 05:22:39 pm
Quote

I recommend opening a bug report so this issue can be tracked:
https://github.com/jmpessoa/lazandroidmodulewizard/issues

Done.

thanks to all
Title: Re: App Crash after update lazarus + LAMW
Post by: WayneSherman on June 08, 2021, 05:27:06 pm
Thanks.  Reference Github Issue:
https://github.com/jmpessoa/lazandroidmodulewizard/issues/384
Title: Re: App Crash after update lazarus + LAMW
Post by: ADiV on June 08, 2021, 05:54:00 pm
Hi guys,

After many nights trying things to solve the error that when updating the android version the apps were blocked. The solution was very simple to separate "gApp.CreateForm" and place it in "controls.lpr"

Code: Pascal  [Select][+][-]
  1. begin
  2.   gApp:= jApp.Create(nil);{AndroidWidget.pas}
  3.   gApp.Title:= 'My Android Bridges Library';
  4.   gjAppName:= 'com.example.appdemo1';{AndroidWidget.pas}
  5.   gjClassName:= 'com/example/appdemo1/Controls';{AndroidWidget.pas}
  6.   gApp.AppName:=gjAppName;
  7.   gApp.ClassName:=gjClassName;
  8.   gApp.Initialize;
  9.  
  10.   gApp.CreateForm(TAndroidModule2, AndroidModule2);
  11.   gApp.CreateForm(TAndroidModule3, AndroidModule3);
  12.   gApp.CreateForm(TAndroidModule4, AndroidModule4);
  13.   gApp.CreateForm(TAndroidModule5, AndroidModule5);
  14.   gApp.CreateForm(TAndroidModule6, AndroidModule6);
  15.   gApp.CreateForm(TAndroidModule7, AndroidModule7);
  16.   gApp.CreateForm(TAndroidModule8, AndroidModule8);
  17.   gApp.CreateForm(TAndroidModule9, AndroidModule9);
  18.   gApp.CreateForm(TAndroidModule10, AndroidModule10);
  19.   gApp.CreateForm(TAndroidModule11, AndroidModule11);
  20.   gApp.CreateForm(TAndroidModule12, AndroidModule12);
  21.   gApp.CreateForm(TAndroidModule13, AndroidModule13);
  22.   gApp.CreateForm(TAndroidModule14, AndroidModule14);
  23.  
  24.   gApp.CreateForm(TAndroidModule1, AndroidModule1);
  25. end.

Creating the secondary forms first and the main one last.

Then I usually create a code in the main form that initializes all the forms. And finally I am calling each form with the "Show" method as needed.
Title: Re: App Crash after update lazarus + LAMW
Post by: ADiV on June 08, 2021, 05:55:24 pm
A new version of "AppDemo1" is already uploaded to github with this bug fixed.
Title: Re: App Crash after update lazarus + LAMW
Post by: WayneSherman on June 08, 2021, 06:14:45 pm
After many nights trying things to solve the error that when updating the android version the apps were blocked. The solution was very simple to separate "gApp.CreateForm" and place it in "controls.lpr"...
Creating the secondary forms first and the main one last.

For resource management, it is often desirable to create forms only when needed instead of creating all of them at the start.  Is it no longer possible to create and show forms (modules) dynamically when they are needed?  (which is a common pattern in Object Pascal)


Title: Re: App Crash after update lazarus + LAMW
Post by: ADiV on June 08, 2021, 06:37:52 pm
After many nights trying things to solve the error that when updating the android version the apps were blocked. The solution was very simple to separate "gApp.CreateForm" and place it in "controls.lpr"...
Creating the secondary forms first and the main one last.

For resource management, it is often desirable to create forms only when needed instead of creating all of them at the start.  Is it no longer possible to create and show forms (modules) dynamically when they are needed?  (which is a common pattern in Object Pascal)

If it is possible to create them, from my experience if you have an app that dynamically creates forms and the user of your app updates their mobile (security update for example) your app will stop working and will generate a fatal error when creating a form dynamically. With which you will have to uninstall the app and reinstall it so that it works again.
Title: Re: App Crash after update lazarus + LAMW
Post by: ADiV on June 08, 2021, 06:40:54 pm
Actually, when a "gApp.CreateForm" is done, it hardly consumes resources, the resources are consumed when the ".Init (gApp)" is done, which can be done anywhere in the app.
Title: Re: App Crash after update lazarus + LAMW
Post by: Mongkey on June 09, 2021, 03:48:00 am
let say your first creation form named splash, then you also want create setting form, the case would be like this picture attached.

if want calling setting form, just by calling setting.show on every desired form you want to call.

i already tested my app on android 11 emulator and it was surprisingly ok.
Title: Re: [SOLVED] App Crash after update lazarus + LAMW
Post by: schumi on June 14, 2021, 06:33:16 pm
Hi,
work's with ADiV's way and also Mongkey's way too

thank you
Title: Re: [SOLVED] App Crash after update lazarus + LAMW
Post by: jmpessoa on June 14, 2021, 06:56:51 pm
Quote
Hi,
work's with ADiV's way and also Mongkey's way too

Nice!

Thank you!
Title: Re: [SOLVED] App Crash after update lazarus + LAMW
Post by: jmpessoa on July 05, 2021, 12:14:35 pm

Hi, All

About "App Crash after update lazarus + LAMW"

We just apply a patch to try improve and fix some  issues pointed here!


Thanks to everyone!
TinyPortal © 2005-2018