flutter-plugins icon indicating copy to clipboard operation
flutter-plugins copied to clipboard

[pasteboard] Copying image to clipboard throws PlatformException on Android

Open FuturisticGoo opened this issue 6 months ago • 0 comments

Trying to copy an image to clipboard using Pasteboard.writeImage (Android setup was done already) fails with the following error:

I/flutter (28309): PlatformException(Error, Failed to write image, Failed to find configured root that contains /data/data/futuristicgoo.emotic.debug/cache/3eb33b68-e614-45f3-a8f3-68dd913bb9ad.png, null)
I/flutter (28309): Stacktrace: #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
I/flutter (28309): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:370:18)
I/flutter (28309): <asynchronous suspension>
I/flutter (28309): #2      PasteboardPlatformIO.writeImage (package:pasteboard/src/pasteboard_platform_io.dart:66:7)
I/flutter (28309): <asynchronous suspension>
I/flutter (28309): #3      copyImageToClipboard (package:emotic/core/helper_functions.dart:83:7)
I/flutter (28309): <asynchronous suspension>

Reproduce Steps

Steps to reproduce the behavior:

  1. Do Android setup steps - modifying the AndroidManifest.xml and adding the provider_paths.xml file as mentioned in README
  2. Use Pasteboard.writeImage(imageBytes) API on Android 15
  3. See error

Expected behavior

The image copies without any error

Version:

  • Flutter Version: 3.29.3
  • OS: Android 15 (don't know if this is version specific)
  • plugin: pasteboard: 0.4.0

Additional context

I was able to fix it by adding the following to provider_paths.xml

    <cache-path
        name="cache"
        path="." />

So I guess this should be added to the README.md?
Thank you for your work btw ^_^

FuturisticGoo avatar May 23 '25 15:05 FuturisticGoo