How to Add Java.Awt.Image Package in Android

How to add java.awt.image package in Android

The Java AWT classes contain native code, so unless someone ports that native code to Android, you are out of luck. And, they won't port it, because as it was pointed out above, Android has its own graphics libraries (android.graphics).

How can I import java.awt.image.BufferedImage in Android Studio

You can't.

The AWT package is not supported in Android, you need to change your implementation to use the Android classes.

See these similar questions:

Porting AWT graphics code to Android

How to add java AWT image package in Android

Using AWT with Android

Android Studio cannot find sun.awt.image package and import java.awt.color.ColorSpace

Don't use the visualization package for anything on Android. It's based off on swing which isn't supported on Android. Use the android package in integration. It has similar functions for visualizing data.

https://github.com/lessthanoptimal/BoofAndroidDemo

that might be useful for you.

Android: The type java.awt.Image cannot be resolved. It is indirectly referenced from required .class files

Found solution:

go to project properties
java build pata->Add library

and add JRE System Library and click finish. Now you can use java.awt package :)

Android Studio - error: package java.awt.geom does not exist

@CommonsWare suggested that i not use java.awt library and that is probably sound longterm advice.

On the other hand, to solve the problem at hand, i downloaded the library, unzipped the file and placed the jar file (java-rt-jar-stubs-1.5.0.jar) in libs folder.

I then right-clicked on the jar file and chose Add as library.

Problem solved.

How to convert java.awt.Image in Bitmap in android


Is there any way to set java.awt.Image in ImageView?

Short answer: No.

You can't use Image, BufferedImage (java.awt package) or ImageIO (javax.imageio package) from Android. So I'm guessing the error you see is related to that.

Maybe if you try to ask how to achieve your goal, rather than this specific implementation issue, maybe we could help you further. :-)



Related Topics



Leave a reply



Submit