Recent

Author Topic: jOpenDialog crashes in Android 10  (Read 17724 times)

neuro

  • Jr. Member
  • **
  • Posts: 62
jOpenDialog crashes in Android 10
« on: July 26, 2021, 03:46:00 am »
The sample project “AppOpenFileDialogDemo1”
works in Android 4.3 (32-bit, device: Samsung Galaxy S3),
however fails to work in Android 10 (64-bit, device: Samsung Galaxy S9).
In sample project both buttons “Get File List” and “jOpenDialog1.Show()” crash the app when running in Android 10.
The following code also crashes in Android 10:
Code: Pascal  [Select][+][-]
  1. listFile:= Self.GetFileList(Self.GetEnvironmentDirectoryPath(dirDownloads));

How to fix this bug of jOpenDialog?

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: jOpenDialog crashes in Android 10
« Reply #1 on: July 26, 2021, 04:06:41 am »

Maybe you need handle file permissions....

(Please,  see jCameraDemo or others..... how to handle file permissions....)
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

neuro

  • Jr. Member
  • **
  • Posts: 62
Re: jOpenDialog crashes in Android 10
« Reply #2 on: July 26, 2021, 04:28:04 am »
“AppCameraDemo” also fails to work in Android 10.
The app writes “'Success! ['+manifestPermission+'] Permission grant!!!”,
however when the button “Take Photo!” is pressed, the app crashes.
Just try it yourself in Android 10.
« Last Edit: July 26, 2021, 04:31:06 am by neuro »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: jOpenDialog crashes in Android 10
« Reply #3 on: July 26, 2021, 05:10:42 am »
Ok... but you can get from "AppCameraDemo" the code to handle file permission...
« Last Edit: July 26, 2021, 05:33:36 am by jmpessoa »
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

neuro

  • Jr. Member
  • **
  • Posts: 62
Re: jOpenDialog crashes in Android 10
« Reply #4 on: July 26, 2021, 05:18:30 am »
File permissions are invoked and granted successfully,
however file permissions do not help – the app crashes in aarch64 Android 10.
Do you have aarch64 Android 10 device for testing “AppOpenFileDialogDemo1” and "AppCameraDemo"?
On which device you have done the testing?

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: jOpenDialog crashes in Android 10
« Reply #5 on: July 26, 2021, 05:28:54 am »

Quote
aarch64...

No...

Try "Run"  -->  "Clean up build"

So you will get a clear "arm32"  ...

Then  select others builds (chipset)

Lazarus menu "Project" --> "Projec Options" --> "[LAMW] ...." ---> "Build"

"Run"  -->  "Clean up build"

Then  "Run"  --> "[LAMW] Build Android Apk and Run"
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

neuro

  • Jr. Member
  • **
  • Posts: 62
Re: jOpenDialog crashes in Android 10
« Reply #6 on: July 26, 2021, 05:50:11 am »
I have more than 20 years of programming experience.
“Clean up build” was the first thing which I already tried in order to fix the problem before writing to this forum.
“Clean up build” does not help. File permissions do not help.
LAMW has a bug which needs to be fixed – jOpenDialog crashes on aarch64 Android 10 device.

Code: Pascal  [Select][+][-]
  1. listFile:= Self.GetFileList(Self.GetEnvironmentDirectoryPath(dirDownloads));
also crashes on aarch64 Android 10 device.
« Last Edit: July 26, 2021, 05:53:19 am by neuro »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: jOpenDialog crashes in Android 10
« Reply #7 on: July 26, 2021, 06:52:29 am »

Quote
I have more than 20 years of programming experience.

Good!

Can you, please,  put here any reference appointed by run time log error ?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

neuro

  • Jr. Member
  • **
  • Posts: 62
Re: jOpenDialog crashes in Android 10
« Reply #8 on: July 26, 2021, 07:48:22 am »
07-26 08:43:20.371 22961 22961 E AndroidRuntime: FATAL EXCEPTION: main
07-26 08:43:20.371 22961 22961 E AndroidRuntime: Process: com.example.appopenfiledialogdemo1, PID: 22961
07-26 08:43:20.371 22961 22961 E AndroidRuntime: java.lang.NullPointerException: Attempt to get length of null array
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at com.example.appopenfiledialogdemo1.jOpenDialog.refresh(jOpenDialog.java:193)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at com.example.appopenfiledialogdemo1.jOpenDialog.access$300(jOpenDialog.java:26)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at com.example.appopenfiledialogdemo1.jOpenDialog$1.onItemClick(jOpenDialog.java:64)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at android.widget.AdapterView.performItemClick(AdapterView.java:374)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at android.widget.AbsListView.performItemClick(AbsListView.java:1736)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at android.widget.AbsListView$PerformClick.run(AbsListView.java:4207)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at android.widget.AbsListView$7.run(AbsListView.java:6692)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:883)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:100)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:237)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:8167)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
« Last Edit: July 26, 2021, 07:50:42 am by neuro »

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: jOpenDialog crashes in Android 10
« Reply #9 on: July 26, 2021, 07:21:49 pm »

Quote
07-26 08:43:20.371 22961 22961 E AndroidRuntime: java.lang.NullPointerException: Attempt to get length of null array
07-26 08:43:20.371 22961 22961 E AndroidRuntime:        at com.example.appopenfiledialogdemo1.jOpenDialog.refresh(jOpenDialog.java:193)

Yes,  looks like the code don't handle an empty directory..... 

Are you testing on an empty directory?
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

neuro

  • Jr. Member
  • **
  • Posts: 62
Re: jOpenDialog crashes in Android 10
« Reply #10 on: July 26, 2021, 08:16:55 pm »
Quote
Are you testing on an empty directory?
No, the directory is not empty.
Your questions make the impression that you don’t have aarch64 Android 10 device for code testing.
Please write your list of Android devices which you have at your disposal for code testing.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: jOpenDialog crashes in Android 10
« Reply #11 on: July 26, 2021, 08:42:24 pm »
 
Quote
Please write your list of Android devices which you have at your disposal for code testing.

Yes, I don't have Android 10 aarch64  ;D

My device list:  4.3 arm32,  5.01 arm32, 6.01 arm32,  7 arm32 and  9 aarch64
Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

neuro

  • Jr. Member
  • **
  • Posts: 62
Re: jOpenDialog crashes in Android 10
« Reply #12 on: July 26, 2021, 09:53:24 pm »
Please test “AppOpenFileDialogDemo1” on 9 aarch64 and write us the results.

jmpessoa

  • Hero Member
  • *****
  • Posts: 2296
Re: jOpenDialog crashes in Android 10
« Reply #13 on: July 27, 2021, 02:47:20 am »

Quote
Please test “AppOpenFileDialogDemo1” on 9 aarch64 and write us the results.....

Yes, it works!

So what I can do now is  improve de code to try fix this error:

Quote
07-26 08:43:20.371 22961 22961 E AndroidRuntime: java.lang.NullPointerException: Attempt to get length of null array
07-26 08:43:20.371 22961 22961 E AndroidRuntime: at com.example.appopenfiledialogdemo1.jOpenDialog.refresh(jOpenDialog.java:193)

You can get a modified (robust/defensive)  "jOpenDialog.java" code in the attachment...
[put it in LAWM folder "...\android_wizard\smartdesigner\java"]




Lamw: Lazarus Android Module Wizard
https://github.com/jmpessoa/lazandroidmodulewizard

neuro

  • Jr. Member
  • **
  • Posts: 62
Re: jOpenDialog crashes in Android 10
« Reply #14 on: July 27, 2021, 03:36:58 am »
Your updated “jOpenDialog.java” now does not crash on Android 10 when “jOpenDialog1.Show()” button is clicked,
however the problem still remains because the returned file list is empty,
jOpenDialog does not see any files or directories.
It still fails to work in Android 10. Still needs to be fixed further.

 

TinyPortal © 2005-2018