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] A resource failed to call close. #1697

Open
GeorgeKamal opened this issue Feb 4, 2025 · 0 comments
Open

[Android] A resource failed to call close. #1697

GeorgeKamal opened this issue Feb 4, 2025 · 0 comments
Assignees
Labels
feature-candidate This issue might result in a feature to be implemented

Comments

@GeorgeKamal
Copy link

Describe the bug
After picking a file, I get this message in my terminal. I don't know how much should I worry about it (potential memory leaks?). Unfortunately, I am not sure what exactly in the file picker package causes it beacuse I don't always getting after picking a file. The file is loaded correctly, regardless of this message.
Message: System: A resource failed to call close
After executing: await FilePicker.platform.pickFiles(...)

Platform

  • Android

Platform OS version
Android 15 (SDK 35) running on emulator.

How are you picking?

Future<void> importData() async {
-->FilePickerResult? result = await FilePicker.platform.pickFiles(type: FileType.custom, allowedExtensions: Constants.extensions); <-- from this line
    if (result != null) {
      try {
        File file = File(result.files.single.path!);
        String importedJsonString = file.readAsStringSync();
        // rest of code
    }
}

Error Log

D/FilePickerUtils( 7466): Allowed file extensions mimes: [application/json]
D/FilePickerDelegate( 7466): Selected type */*
D/VRI[MainActivity]( 7466): visibilityChanged oldVisibility=true newVisibility=false
I/FilePickerUtils( 7466): Caching from URI: content://com.android.providers.downloads.documents/document/35
D/FilePickerUtils( 7466): File loaded and cached at:/data/user/0/com.x.y/cache/file_picker/1738677098890/data_30-01-2025_1903.json
D/FilePickerDelegate( 7466): File path:[com.mr.flutter.plugin.filepicker.FileInfo@6787436]
I/com.x.y( 7466): Background concurrent mark compact GC freed 1097KB AllocSpace bytes, 66(3432KB) LOS objects, 49% free, 3144KB/6288KB, paused 25.166ms,11.036ms total 394.245ms
D/StrictMode( 7466): StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack 
trace but never released. See java.io.Closeable for information on avoiding resource leaks.
D/StrictMode( 7466):    at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:2011)
D/StrictMode( 7466):    at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:336)
D/StrictMode( 7466):    at java.io.FileOutputStream.finalize(FileOutputStream.java:560)
D/StrictMode( 7466):    at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:370)
D/StrictMode( 7466):    at java.lang.Daemons$FinalizerDaemon.processReference(Daemons.java:350)
D/StrictMode( 7466):    at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:322)
D/StrictMode( 7466):    at java.lang.Daemons$Daemon.run(Daemons.java:131)
D/StrictMode( 7466):    at java.lang.Thread.run(Thread.java:1012)
D/StrictMode( 7466): Caused by: java.lang.Throwable: Explicit termination method 'close' not called
D/StrictMode( 7466):    at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:288)
D/StrictMode( 7466):    at dalvik.system.CloseGuard.open(CloseGuard.java:257)
D/StrictMode( 7466):    at java.io.FileOutputStream.<init>(FileOutputStream.java:275)
D/StrictMode( 7466):    at java.io.FileOutputStream.<init>(FileOutputStream.java:147)
D/StrictMode( 7466):    at com.mr.flutter.plugin.filepicker.FileUtils.openFileStream(FileUtils.java:300)
D/StrictMode( 7466):    at com.mr.flutter.plugin.filepicker.FilePickerDelegate$1.run(FilePickerDelegate.java:157)
D/StrictMode( 7466):    ... 1 more
D/StrictMode( 7466): StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack 
trace but never released. See java.io.Closeable for information on avoiding resource leaks.
D/StrictMode( 7466):    at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:2011)
D/StrictMode( 7466):    at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:336)
D/StrictMode( 7466):    at android.util.CloseGuard.warnIfOpen(CloseGuard.java:170)
D/StrictMode( 7466):    at android.os.ParcelFileDescriptor.finalize(ParcelFileDescriptor.java:1121)
D/StrictMode( 7466):    at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:370)
D/StrictMode( 7466):    at java.lang.Daemons$FinalizerDaemon.processReference(Daemons.java:350)
D/StrictMode( 7466):    at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:322)
D/StrictMode( 7466):    at java.lang.Daemons$Daemon.run(Daemons.java:131)
D/StrictMode( 7466):    at java.lang.Thread.run(Thread.java:1012)
D/StrictMode( 7466): Caused by: java.lang.Throwable: Explicit termination method 'close' not called
D/StrictMode( 7466):    at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:288)
D/StrictMode( 7466):    at dalvik.system.CloseGuard.open(CloseGuard.java:257)
D/StrictMode( 7466):    at android.util.CloseGuard.open(CloseGuard.java:153)
D/StrictMode( 7466):    at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:216)
D/StrictMode( 7466):    at android.os.ParcelFileDescriptor$2.createFromParcel(ParcelFileDescriptor.java:1181)
D/StrictMode( 7466):    at android.os.ParcelFileDescriptor$2.createFromParcel(ParcelFileDescriptor.java:1172)
D/StrictMode( 7466):    at android.content.res.AssetFileDescriptor.<init>(AssetFileDescriptor.java:708)
D/StrictMode( 7466):    at android.content.res.AssetFileDescriptor$1.createFromParcel(AssetFileDescriptor.java:721)
D/StrictMode( 7466):    at android.content.res.AssetFileDescriptor$1.createFromParcel(AssetFileDescriptor.java:719)
D/StrictMode( 7466):    at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:817)
D/StrictMode( 7466):    at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:2043)
D/StrictMode( 7466):    at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1858)
D/StrictMode( 7466):    at android.content.ContentResolver.openInputStream(ContentResolver.java:1528)
D/StrictMode( 7466):    at com.mr.flutter.plugin.filepicker.FileUtils.openFileStream(FileUtils.java:303)
D/StrictMode( 7466):    at com.mr.flutter.plugin.filepicker.FilePickerDelegate$1.run(FilePickerDelegate.java:157)
D/StrictMode( 7466):    ... 1 more

Flutter Version details

flutter doctor -v
[√] Flutter (Channel stable, 3.27.0, on Microsoft Windows [Version 10.0.19045.5371], locale en-GB)
    • Flutter version 3.27.0 on channel stable at C:\Users\#####\AppData\Local\FlutterSDK
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 8495dee1fd (8 weeks ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2

[☠] Windows Version (the doctor check crashed)
    X Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at      https://github.com/flutter/flutter/issues.
    X Error: Flutter failed to run "powershell -command Get-Process | Format-List Path". The flutter tool cannot access the file or        
      directory.
      Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
    • #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
      #1      _throwFileSystemException (package:flutter_tools/src/base/error_handling_io.dart:856:3)
      #2      _handleWindowsException (package:flutter_tools/src/base/error_handling_io.dart:846:3)
      #3      _run (package:flutter_tools/src/base/error_handling_io.dart:584:7)
      <asynchronous suspension>
      #4      WindowsVersionValidator._topazScan (package:flutter_tools/src/windows/windows_version_validator.dart:40:48)
      <asynchronous suspension>
      #5      WindowsVersionValidator.validate (package:flutter_tools/src/windows/windows_version_validator.dart:81:9)
      <asynchronous suspension>
      #6      Future.any.onValue (dart:async/future.dart:614:5)
      <asynchronous suspension>


[!] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at C:\Users\#####\AppData\Local\Android\Sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = C:\Users\#####\AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)
    ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.1)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.7.34009.444
    • Windows 10 SDK version 10.0.22621.0
    X The current Visual Studio installation is incomplete.
      Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.

[√] Android Studio (version 2024.1)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0--11609105)

[√] VS Code (version 1.96.2)
    • VS Code at C:\Users\#####\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.102.0

[√] Connected device (4 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 15 (API 35) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [Version 10.0.19045.5371]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 132.0.6834.160
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 132.0.2957.140

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 3 categories.
@GeorgeKamal GeorgeKamal added the new issue An issue that hasn't yet been seen from the maintainer label Feb 4, 2025
@navaronbracke navaronbracke self-assigned this Feb 7, 2025
@navaronbracke navaronbracke added feature-candidate This issue might result in a feature to be implemented and removed new issue An issue that hasn't yet been seen from the maintainer labels Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-candidate This issue might result in a feature to be implemented
Projects
None yet
Development

No branches or pull requests

2 participants