-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Platform
Android API 34
Plugin
share_plus
Version
9.0.0
Flutter SDK
3.22.0
Steps to reproduce
I am using share_plus
to share a captured widget (Uint8List
). The code below shows how I am saving the "image" to a temp directory, and then trying to share it (two ways, using XFile(path)
and XFile.fromData(data)
).
Both started to throw an exception after I updated to Flutter 3.22.0, shown in the logs.
The same code works without problems on iOS phones with iOS 17.5 - and used to work on Android as well. I didn't update that part of the code in a while.
Code Sample
Future<ShareResult> shareImage(Uint8List bytes) async {
try {
String path = (await getTemporaryDirectory()).path;
File tempFile = File('$path/drawing.png');
tempFile.writeAsBytesSync(bytes);
return await Share.shareXFiles(
[XFile.fromData(bytes)],
);
} catch (e) {
print(e.toString());
return Future.error('Error creating temporary file');
}
}
And
Future<ShareResult> shareImage(Uint8List bytes) async {
try {
String path = (await getTemporaryDirectory()).path;
File tempFile = File('$path/drawing.png');
tempFile.writeAsBytesSync(bytes);
return await Share.shareXFiles(
[XFile(tempFile.path)],
);
} catch (e) {
print(e.toString());
return Future.error('Error creating temporary file');
}
}
### Logs
```shell
I/flutter ( 5943): PlatformException(Share failed, Failed to find configured root that contains /data/data/app.id/cache/share_plus/drawing.png, java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/app.id/cache/share_plus/drawing.png
I/flutter ( 5943): at androidx.core.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:849)
I/flutter ( 5943): at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:452)
I/flutter ( 5943): at dev.fluttercommunity.plus.share.Share.getUrisForPaths(Share.kt:188)
I/flutter ( 5943): at dev.fluttercommunity.plus.share.Share.shareFiles(Share.kt:96)
I/flutter ( 5943): at dev.fluttercommunity.plus.share.MethodCallHandler.onMethodCall(MethodCallHandler.kt:46)
I/flutter ( 5943): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
I/flutter ( 5943): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
I/flutter ( 5943): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMes
E/flutter ( 5943): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Error creating temporary file
I/flutter ( 5943): PlatformException(Share failed, Failed to find configured root that contains /data/data/app.id/cache/share_plus/4cd-1fde-861b-f1ecb4ceeecd.octet-stream, java.lang.IllegalArgumentException: Failed to find configured root that contains /data/data/app.id/cache/share_plus/4cd-1fde-861b-f1ecb4ceeecd.octet-stream
Flutter Doctor
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
• Flutter version 3.22.0 on channel stable at /Users/lucanicoletti/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5dcb86f68f (11 days ago), 2024-05-09 07:39:20 -0500
• Engine revision f6344b75dc
• Dart version 3.4.0
• DevTools version 2.34.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/lucanicoletti/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/lucanicoletti/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.3)
• Android Studio at /Applications/Android Studio.app/Contents
• 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-17.0.10b1087.21-11572160)
[✓] VS Code (version 1.89.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.88.0
[✓] Connected device (5 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 14 (API 34) (emulator)
• iPhone (mobile) • 00008130-0009681424C1401C • ios • iOS 17.5 21F79
• macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.4.1 23E224 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.208
[✓] Network resources
• All expected network resources are available.
• No issues found!
Checklist before submitting a bug
- I searched issues in this repository and couldn't find such bug/problem
- I Google'd a solution and I couldn't find it
- I searched on StackOverflow for a solution and I couldn't find it
- I read the README.md file of the plugin
- I'm using the latest version of the plugin
- All dependencies are up to date with
flutter pub upgrade
- I did a
flutter clean
- I tried running the example project