0

I'm making an android app. I reference a java project called recognition. When I call a function from it, from my android project, it crashes, with this log:

The java project uses BufferedImage objects and is set to JRE 1.6.

Does anyone know what the problem is?

Thanks

EDIT:

I think the problem is Path requires 1.7, but android is using 1.6 How can I fix that?

08-28 21:52:04.595: E/AndroidRuntime(21763): FATAL EXCEPTION: main
08-28 21:52:04.595: E/AndroidRuntime(21763): java.lang.NoClassDefFoundError: java.nio.file.Paths
08-28 21:52:04.595: E/AndroidRuntime(21763):    at recognition.Recognize.getImage(Recognize.java:168)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at recognition.Recognize.getInitialImage(Recognize.java:80)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at recognition.Recognize.runAnalysis(Recognize.java:46)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.arin.SpeciesScreen.onActivityResult(SpeciesScreen.java:131)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.app.Activity.dispatchActivityResult(Activity.java:5361)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.app.ActivityThread.deliverResults(ActivityThread.java:3201)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:3248)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.app.ActivityThread.access$1200(ActivityThread.java:143)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.os.Looper.loop(Looper.java:137)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at android.app.ActivityThread.main(ActivityThread.java:4950)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at java.lang.reflect.Method.invokeNative(Native Method)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at java.lang.reflect.Method.invoke(Method.java:511)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
08-28 21:52:04.595: E/AndroidRuntime(21763):    at dalvik.system.NativeStart.main(Native Method)

This is the getImage function

private static BufferedImage getImage(String from) throws IOException {
    Path path = Paths.get(from);
    File file = path.toFile();

    if (file.exists()) {
        InputStream stream = Files.newInputStream(path);
        BufferedImage bufferedImage = ImageIO.read(stream);

        BufferedImage NewBufferedImage = convertToARGB(bufferedImage);
        bufferedImage.flush();
        bufferedImage = NewBufferedImage;

        return bufferedImage;
    }
    return null;
}

This is the android build order:

enter image description here enter image description here

omega
  • 40,311
  • 81
  • 251
  • 474

1 Answers1

0

problem:

java.nio.file.Paths

The Paths class does not exist in android SDK thus giving you NoClassDefFoundError java oracle and dalvik java android have different libraries mostly of them is implemented in android but BufferedImage is none of them. Consider using Bitmap instead to get the image.

you can go here to check the list of class in java.nio package in android

Community
  • 1
  • 1
Rod_Algonquin
  • 26,074
  • 6
  • 52
  • 63