Has anyone tried to use javax.persistence on Android? - android

Has anyone tried to use javax.persistence on Android by getting the source or jar and adding it to their project?

Odds are, you will not be able to add the JAR or source. The Android build tools actively block you from importing much in the java.* and javax.* packages.
If Apache Harmony has an implementation of javax.persistence, and you are willing to refactor it to a new package (e.g., via jarjar), you can give it a try.

Related

changing or upgrading built-in org.json libraries, is possible and a good idea?

My application depends a lot on the JSON library org.json.*. This package is built-in into Android standard libraries, something I didn't know because I also included it in my source tree.
I need to use a function (JSONArray.remove) that is not supported on the built-in package, while it is in the source distribution jar from org.json (that I include in my project). So what happens is, everything compiles & all, but I get java.lang.NoSuchMethodError: org.json.JSONArray.remove at runtime.
My question is, how can I tell eclipse or Android to use the org.json.* from my source tree instead of its built-in version?
And a sub-question: Is it a good idea at all? May the built-in JSON package have native-level improvements or something like that vs. the official source code distribution?
My question is, how can I tell eclipse or Android to use the org.json.* from my source tree instead of its built-in version?
You can't. You do not control the runtime classpath, and the firmware always wins.
You are welcome to use jarjar or a similar tool to move your copy of the org.json classes into a new package. Or, find a better JSON library -- there's lots of them out there.

Scala library in build path doesn't expose its version (Android App Dev)

I am receiving the following error when I add android-scala.jar to the build path of my android application: The scala library found in the build path doesn't expose its version. Please replace the scala library with the scala container or a valid scala library jar. Does anyone have any idea what maybe causing this or a potential solution to this problem?? Let me know if more information is helpful; however, I cannot even get the emulator to launch with the current error.
Thanks,
Michael
The library needs to be called scala-library.jar, and it has to contain the original library.properties file from the standard Scala library jar.

Import javax.namespace in Android

I am trying to import certain classes like
javax.namespace.QName
and
org.apache.axis2.*
but I am unable to use these classes in my program. I actually got this code after converting a wsdl file into java using wsdl2java. Can anyone help me which libraries I need to use in order to get support for these classes. Also I shall be greatly thankful to you if someone can guide me about how can I add external libraries in eclipse in my Android project.
Looking forward to some useful responses.
Thanks
You should read some stuff about dalvik http://en.wikipedia.org/wiki/Dalvik_(software)
Dalvik VM is not JVM, it run different bytecode, so you have to prepare jars by tools/add sources to you project as library. But javax is a Java EE package as I know, and it has a lot of dependencies (could be even incompatible).
For eclipse:
1) create android project , go to project properties > Android > check Is Library
2) add library to project (the same way)

java.lang.NoSuchMethodError for method on the build path

I have a basic Android project created in Eclipse Indigo. I have a third-party library on my build path, and it is called is used when I instantiate a class from that library in my initial activity.
Although the app build just fine, I encounter the following error:
10-02 19:51:17.311: ERROR/AndroidRuntime(314): java.lang.NoSuchMethodError: org.apache.http.conn.scheme.Scheme.<init>
Earlier in logcat, I do observe the following error message:
10-02 19:50:48.670: DEBUG/dalvikvm(295): DexOpt: not verifying 'Lorg/apache/http/conn/scheme/Scheme;': multiple definitions
This class is included in the third-party JAR; is it used by Android somehow/somewhere to suggest a conflict or other source of "multiple definitions?"
Thanks!
How does one reconcile the conflict - do I have crack open the third-party JAR and exclude the conflicting files?
My guess is that this would not help, though you can certainly try it. Somebody would appear to be trying to call a method on Scheme that perhaps exists in the JAR's own private copy of that class but is not in the Android SDK.
If the third-party JAR in question is Apache HttpClient, simply don't put that JAR in your build path, as HttpClient is already part of Android, and stick to methods that are in the SDK. If the third-party JAR is not Apache HttpClient, I suspect that once you remove their duplicate org.apache.http classes, that something else will break that depended on their own private version of those classes. If that is the case, you should probably take it up with the third-party developer directly, to work with them on Android support for their JAR. You might be able to use tools like jarjar to get past this, but I would not count on it.
You can try something like jarjar, it can break open the jars and rename the packages to a different path at build time. This avoids conflicts like the ones you're having. I'm just not sure it will work with Android.

How can I use jar libraries in Android compiled with packages that Android doesn't have

I need to import a couple of jars that where compiled under the full implementation of java. I know that Android doesn't use all the packages that java has to offer. My question is: Is it possible to import them without creating errors? Is there a tool that can convert jars to android jars? if so, can some examples be provided. Any help is much appreciated.
Is it possible to import them without creating errors?
If the JARs refer to classes that Android does not have, no.
Is there a tool that can convert jars to android jars?
There is no such thing as "android jars".
If you have the source code to the JARs in question, between modifying that source code and modifying copies of the missing classes from Apache Harmony, you may be able to get stuff working. However, you cannot just put java.* or javax.* classes in your project -- you will have to refactor them into new packages. Also, depending on what classes are missing, this may take thousands of developer-months to accomplish (e.g., reimplementing Swing using 2D Canvas APIs).

Categories

Resources