-1

Running a Flutter project has worked fine until adding a call to ImageIO within a dart package java file ImagePickerPlugin.java. The import is at the top and command-click shows the class in the IDE, but compiling fails.

try {
  Image image = ImageIO.read(sourceimage);
} catch (IOException e) {
  e.printStackTrace();
}

Comile error:

Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...
/Users/marchampson/.pub-cache/hosted/pub.dartlang.org/image_picker0.3.0/android/src/main/java/io/flutter/plugins/imagepicker/ImagePickerPlugin.java:27: error: package javax.imageio does not exist
import javax.imageio.ImageIO;

Anybody have any issues when changing dart packages with IntelliJ IDEA? Thanks

Marc Hampson
  • 257
  • 1
  • 4
  • 17
  • Does this mean you modified a file inside `~/.pub-cache`? You shouldn't do that. You should rather clone the package and add that clone as dependency to your Flutter project. – Günter Zöchbauer Mar 15 '18 at 10:43
  • Ah, ok, whoops. I'll do that instead. I assume that's an observation rather than something that might fix my error? Thanks – Marc Hampson Mar 15 '18 at 10:47
  • Not sure. I haven't developed plugins myself yet, but it's usually a bad idea to change files in that package cache. – Günter Zöchbauer Mar 15 '18 at 11:00
  • I can see that now. I've cloned it and will se what happens. Good spot, thanks for your help. – Marc Hampson Mar 15 '18 at 11:01
  • No, it doesn't fix that issue but it does mean I can properly source control it and hopefully go for a pull-request in the future. – Marc Hampson Mar 15 '18 at 11:23

1 Answers1

1

This turned out to not be an issue with importing, more that ImageIO isn't available on Android. Found this out via:

Library Java can't resolve in Android Studio 3.1

Have gone another route and all working now.

Marc Hampson
  • 257
  • 1
  • 4
  • 17