Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android crashes on image pick [HUAWEI P30 Pro] - Android 10/11 #1534

Open
1 of 4 tasks
ynnob opened this issue Jun 18, 2024 · 11 comments
Open
1 of 4 tasks

Android crashes on image pick [HUAWEI P30 Pro] - Android 10/11 #1534

ynnob opened this issue Jun 18, 2024 · 11 comments
Labels
new issue An issue that hasn't yet been seen from the maintainer

Comments

@ynnob
Copy link

ynnob commented Jun 18, 2024

Describe the bug
Same as the closed issues #1461 , #1460
Fix should have been #1458

But for me and looking at the comments some other the app is still crashing after selecting an image using the file_picker 8.0.5

Permissions i list in my Manifest:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.USE_BIOMETRIC" />
    <!--Geolocator plugin-->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <!-- Images -->
    <uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
    <uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />

    <uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
    <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
    <uses-permission
        android:name="android.permission.READ_EXTERNAL_STORAGE"
        android:maxSdkVersion="32" />
    <uses-permission
        android:name="android.permission.WRITE_EXTERNAL_STORAGE"
        android:maxSdkVersion="32" />

    <!--Audio Recording-->
    <uses-permission android:name="android.permission.RECORD_AUDIO" />

and in Application-Tag:
android:requestLegacyExternalStorage="true"

Platform

  • Android
  • iOS
  • Web
  • Desktop

Platform OS version
HUAWEI P30 Pro
Android 10

How are you picking?

 result = await FilePicker.platform.pickFiles(
        type: FileType.image,
        allowMultiple: true,
      );

Details to reproduce the issue
Provide all the details to reproduce the issue.

Error Log

E/AndroidRuntime(16782): FATAL EXCEPTION: Thread-9
E/AndroidRuntime(16782): Process: com.my.app, PID: 16782
E/AndroidRuntime(16782): java.lang.RuntimeException: java.io.IOException: Permission denied
E/AndroidRuntime(16782): 	at com.mr.flutter.plugin.filepicker.FileUtils.compressImage(FileUtils.java:111)
E/AndroidRuntime(16782): 	at com.mr.flutter.plugin.filepicker.FilePickerDelegate$2.run(FilePickerDelegate.java:137)
E/AndroidRuntime(16782): 	at java.lang.Thread.run(Thread.java:929)
E/AndroidRuntime(16782): Caused by: java.io.IOException: Permission denied
E/AndroidRuntime(16782): 	at java.io.UnixFileSystem.createFileExclusively0(Native Method)
E/AndroidRuntime(16782): 	at java.io.UnixFileSystem.createFileExclusively(UnixFileSystem.java:317)
E/AndroidRuntime(16782): 	at java.io.File.createTempFile(File.java:2018)
E/AndroidRuntime(16782): 	at com.mr.flutter.plugin.filepicker.FileUtils.createImageFile(FileUtils.java:120)
E/AndroidRuntime(16782): 	at com.mr.flutter.plugin.filepicker.FileUtils.compressImage(FileUtils.java:98)
E/AndroidRuntime(16782): 	... 2 more
I/HwViewRootImpl(16782): removeInvalidNode all the node in jank list is out of time
D/DecorView(16782): showOrHideHighlightView: hasFocus=true; winMode=1; isMrgNull=true
W/InputMethodManager(16782): startInputReason = 1
W/HwRemoteInputMethodManager(16782): isCasting false because IHwDistributedWindowManager is invalid.
D/SessionLifecycleClient(16782): Sending lifecycle 2 to service
D/SessionLifecycleService(16782): Activity backgrounding at 1237470
W/ile.developmen(16782): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/ile.developmen(16782): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/ile.developmen(16782): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
W/ile.developmen(16782): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
W/ile.developmen(16782): Accessing hidden method Lsun/misc/Unsafe;->getObject(Ljava/lang/Object;J)Ljava/lang/Object; (greylist, linking, allowed)
I/Process (16782): Sending signal. PID: 16782 SIG: 9
Lost connection to device.

Flutter Version details

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.22.1, on Microsoft Windows [Version 10.0.19045.4529], locale de-DE)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Enterprise 2022 17.8.3)
[√] Android Studio (version 2023.3)
[√] VS Code (version 1.89.1)
[√] Connected device (4 available)
[√] Network resources

• No issues found!
@ynnob ynnob added the new issue An issue that hasn't yet been seen from the maintainer label Jun 18, 2024
@ynnob
Copy link
Author

ynnob commented Jun 18, 2024

build.gradle:

android {
    namespace = "com.my.app"
    compileSdk = 34
    ndkVersion "26.1.10909125"

    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    // Default Config - Production
    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 21
        targetSdkVersion 34
        versionCode = flutterVersionCode.toInteger()
        versionName = flutterVersionName
        multiDexEnabled true
    }

[...]
}

Edit:
I could confirm the Android Version of this EMUI V12 and it is Android 10 in this case.

Copy link

This issue is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale label Jun 26, 2024
@murat-ti
Copy link

murat-ti commented Jun 29, 2024

Same here, problem in compression, when I set it to 0, the problem dissappears. By default compression value is 30.

@ynnob
Copy link
Author

ynnob commented Jun 29, 2024

Same here, problem in compression, when I set it to 0, the problem dissappears. By default compression value is 30.

Maybe i should set the compression to 0. I didn't even notice that there is a default compression. Thank you!
But anyway i think this is still a bug and the previous issues should not have been closed.

@github-actions github-actions bot removed the stale label Jun 30, 2024
@rafagazani
Copy link

Same problem with xiaomi mi 8 lite
MIUI Global 12.0.3
Android 10 QKQ1.190910.002

I disabled compression and it worked

Copy link

github-actions bot commented Jul 9, 2024

This issue is stale because it has been open for 7 days with no activity.

@github-actions github-actions bot added the stale label Jul 9, 2024
@Amoghpurohit
Copy link

Amoghpurohit commented Jul 15, 2024

Anyone facing this issue just set compressionQuality to 0 and it will work fine (its 30 by default), we can close this issue for now ig

@ynnob
Copy link
Author

ynnob commented Jul 15, 2024

this issue just set compressio

That is just a workaround not a fix.
A native default feature of file_picker should not crash any device.

@rohinton-collins
Copy link

Also just hit this. Wasted a lot of time on permissions etc. trying to get things working. As above, set compressionQuality to zero:

    FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.image, compressionQuality: 0);

This needs to be fixed.

@Amoghpurohit
Copy link

Amoghpurohit commented Jul 15, 2024

this issue just set compressio

That is just a workaround not a fix. A native default feature of file_picker should not crash any device.

we all know this, getting a workaround and moving on is better than waiting for a fix which who knows when, i think, but your right, lets not close the issue

@github-actions github-actions bot removed the stale label Jul 16, 2024
@GopalAngkas
Copy link

I managed to work around with help of permission_hander package

    var compressionQuality = 30;
    var status = await Permission.storage.status;

    if (status.isDenied) {
      status = await Permission.storage.request();
      if (status.isDenied) {
        compressionQuality = 0;
      }
    }

    final result = await FilePicker.platform.pickFiles(
      type: FileType.image,
      compressionQuality: compressionQuality,
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue An issue that hasn't yet been seen from the maintainer
Projects
None yet
Development

No branches or pull requests

6 participants