How to add java.awt.image package in Android - android

I have an external library that relies on the java.awt.Image package. However, the Android library does not contain it. Does anybody know how to add it to Android?
Thanks!

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).

Use JavaCV. http://code.google.com/p/javacv/
Its allready precompiled for Android 2.2 : http://code.google.com/p/javacv/downloads/list

This answer is to justify Hitesh answer after seeing up votes (which misleads). If am wrong, please correct me.
Well, I have also been enthusiast in using few core concepts of Java like Swings and AWT libraries in Android.
Recently I wanted to use java.awt.Color class because it is much better than android.graphics.Color. So done a small research by reading few threads and concluded as 'No we cannot import'. By seeing Hitesh answer I thought I failed my research and found very easiest solution for my problem. Followed the steps for a sample and run my code. Alas!!!
NoClassDefFoundError exception has thrown.
Once again made a small research for concluding Jeffrey (accepted) answer. I found conclusion here. The comment above the method loadLibraries() explains everything. This method has been called in Color class (line 279).

https://stackoverflow.com/a/33210293/5418475
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

Related

Where is the code generated by #Compose located in an android project folder structure?

i'm studying jatpack Compose and trying to read some source code of it. Noticed the Compose annotation is critical in this framework so i want to read the code generated by it to check what is actually done within it. However i cant find where the code locate, and since it's a quit new stuff, nothing could be found through out the internet. Beg for your idea, thanks!
That is a big topic.
The #Composable annotation is not processed by an Annotation Processor that generates source code. Instead Google had built a Kotlin Compiler Plugin that processes the annotation and weaves its magic into the compiled code directly.
Leland Richardson is the engineer that works on this and has explained a lot of what happens behind the curtains. For example, start here:
http://intelligiblebabble.com/compose-from-first-principles/

Snappy compression on Android

I am currently using Gzip to compress attachments in Couchbase on Android. Recently bumped into Snappy, that seems to be an efficient solution, so decided to use Snappy instead of GZip.
Snappy github - https://github.com/xerial/snappy-java
But what I am confused is how to use the Snappy library in Android. I downloaded the latest version of snappy (1.1.2.1) from http://central.maven.org/maven2/org/xerial/snappy/snappy-java/1.1.2.1/ and dropped it in the libs folder of the Android project. I now can reference the Snappy class methods in my Android source code, which made me think that everything was going great so far. Now when I run the app, I get the following error when I call Snappy.compress(byte[] data) -
org.xerial.snappy.SnappyError: [FAILED_TO_LOAD_NATIVE_LIBRARY] no native library is found for os.name=Linux and os.arch=aarch64
org.xerial.snappy.SnappyLoader.findNativeLibrary(SnappyLoader.java:331)
org.xerial.snappy.SnappyLoader.loadNativeLibrary(SnappyLoader.java:171)
org.xerial.snappy.SnappyLoader.load(SnappyLoader.java:152)
org.xerial.snappy.Snappy.<clinit>(Snappy.java:47)
I created a sample java class to test Snappy, and it works great.
So, from my understanding, its missing some native libraries for the Linux kernel, but even from the description on the github page, cannot figure out a way to build the jar file that I can use on Android.
Any help would be greatly appreciated.
Thanks
Looks like Linux/aarch64 for Snappy is in the works, but not yet released:
https://github.com/xerial/snappy-java/issues/134
You could give a shot at https://github.com/dain/snappy. It's a pure java port so no need for native libs.

Android Bootstrap what is that really, what does it do?

According to this link www.androidbootstrap.com/‎ I am wondering what does it really do, what is for? Am I supposed to use it?
I've read all text on this main page but I am still confused and I do not know should I use it.
The main problem is I don't see the point. Could someone tell me what is it for?
I am open for new technologies but here is the example where I don't understand, but they say that using their package will shorten my work on application.
Regards and I am looking for any information.
I am wondering what does it really do
It generates a skeleton Android project containing specific libraries. It is reminiscent of the new-project wizard in Eclipse, just supporting more third-party libraries, particularly ones that may be a bit of a challenge to get working together.
I had a look at this project to provide a quick set up for actionbarsherlock and dagger DI.
I think it’s a good idea as it seeks to provide an android template, with an out the box solution including sherlock and dagger. But I couldn’t get it working on eclipse, and the forum had a lot of people saying the same (I think its designed for Intelij IDEA)
I also looked at androidkickstartr which is more mature, but again had import issues, so just made my own template and imported sherlock and dagger

What is recommended way to include android source code in addition to android SDK?

I am a new developer for android programming. I understand android SDK does not contain all classes from android source code. For example, AtCommandResult.class is missing (hiding) from android.bluetooth package in the SDK.
Sometimes, however, I want to use the hidden code in my app and I wonder what would be the best way to do that. One approach I can think of would be to include its corresponding source code in my project with different package name to avoid conflict with existing core. But problem with this approach would be I have to maintain the code by myself from that point. One or two classes are OK but you know where I am going.
Is there any better way other than bothering google to include the code in the SDK? Thanks in advance.
You may want to use a .AIDL file:
http://developer.android.com/guide/developing/tools/aidl.html
Those can already be used to access for example in Telephony functions.
Code example here:
http://code.google.com/p/auto-answer/source/browse/trunk/src/com/android/internal/telephony/ITelephony.aidl?r=13

Are there Android compatible alternatives to Property Utils?

Is there a handy-dandy equivalent to org.apache.commons.beanutils.PropertyUtils on Android?
I can't seem to use bean utils in my android app due to some dependencies on PropertyDescriptor,and IndexedPropertyDescriptor. So I'm wondering if there are any alternatives?
Basically all I want to do is use a method name as a string "someMethod" and feed that into setMethod(anObject, "someMethod", value), much like PropertyUtils does; but without having to resort to the nasties of reflection...
Or are my hands tied and I need to use Reflection?
There is bridge library which works on Android: android-java-air-bridge.jar. Just include into project path and use all apache beanutils features in your Android project as you could use in ordinary java application. Moreover, there are lot of other classes which moved to this Android supporting library. Look at the list.
There is a possibilty to use libraries or write own code depending on the PropertyUtils. But it sure isn't dandy. You can get the general idea about what has to be done in this thread.
There are apparently some projects who have successfully solved the issue, so you can study thier solution. Take a look at Drawingpad-base and libgdx. You can find PropertyUtils in the package com.madrobot.beans in the first project and com.badlogic.gdx.beans in the second.

Categories

Resources