Dalvik conversion error due to StAX - java

When I add the stax-api-1.0-2.jar in my Android project, I get the following error:
Dx trouble processing "javax/xml/stream/EventFilter.class"
Conversion to Dalvik format failed with error 1
Now I have searched the site and found this "Conversion to Dalvik format failed with error 1" on external JAR and a lot of other similar questions and have tried out the solutions presented in them. Unfortunately, these solutions do not work for me. I have come to the conclusion that the problem is in using this jar itself.
My question is two-fold:
Why does Dalvik conversion fail when using particular core external jar like stax-api-1.0-2.jar but does not fail for javax.json-1.0.4.jar, javax.ws.rs-api-2.0.jar, javax.annotation-api-1.2.jar when these are also core jar files?
Which alternate to stax-api-1.0-2.jar I can use which will not cause this error?

Related

Add lacking libraries to Processing? ( com.sun.tools )

I'm currently writing a library and I want to do some stuff including com.sun.tools.attach.VirtualMachine however in testing I got a NoClassDefError. With a little research I found the following cause:
Processing simply doesn't have com.sun.tools on it's class-path.
I am currently trying to patch it up with a jar file from my java installation (jrt-fs.jar) however it didn't work.
Is it possible to patch up Processing so I can access com.sun.tools?

Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions

My Project shows no errors. Though when I run the application it says please fix the error before running your application. When I looked at Console tab it says
[2015-07-10 19:50:26 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;
[2015-07-10 19:50:26 - NavigationDrawer] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v7/app/ActionBar$DisplayOptions;
I tried searching for the solution but haven't got any.
this is what I have for my support libraries.
Please Help. I got stuck here. Thank you in advance.
You have added several times this same library try to delete it to get only one (android-support-v7-appcompat.jar).
I propose to remove last (at bottom) and first (at top).
I do not know how you android program does, but from my experience these types of errors is the beginning of many erroes own eclipse. I recommend migrate their projects to AndroidStudio an excellent IDE that works without any kind of bugs.

AWS Java SDK Error - java.lang.NoSuchMethodError

I've seen this type of error over here for exceptions that are thrown by various classes, though I haven't found the right solution for mine just yet.
I'm trying to get AWS Java SDK work locally so I can write a test application that reads data from a Kinesis stream.
Problem is, when I run the init() static method I encounter the following error:
Exception in thread "main" java.lang.NoSuchMethodError:
org.apache.http.impl.conn.DefaultClientConnectionOperator.<init>
(Lorg/apache/http/conn/scheme/SchemeRegistry;Lorg/apache/http/conn/DnsResolver;)V
Now, this is not the first error I've been thrown. I've been thrown four or five exceptions prior to this one, and the solution to all of them was just importing some jar's into the project. e.g.:
apache-httpcomponents-httpclient.jar
com.fasterxml.jackson.databind.jar
commons-codec-1.9.jar / commons-codec-1.9-javadoc.jar / commons-codec-1.9-sources.jar
httpclient-4.2.jar
httpcore-4.0.1.jar
I've seen in other threads around here that it could be the version of the httpcore library, however I imported the latest one.
Any ideas how I can resolve this? I'm thinking about starting over, as my project seems to be a heap of imports I'm not sure I'll actually utilize. Furthermore, I can't debug the binary imports of the AWS SDK (or can't I?).
Cheers.
Problem solved, I gradually added the missing libraries to the project and when the apache httpclient jar should be version 4.0 or later, and without any previous version to contradict.
I imported httpclient-4.2.jar and it worked.
Other than that, I just solved the exception that followed by importing joda-time-2.4.jar and it's all up and running.

Multiple dex files + Unable to start activity ComponentInfo

After searching for similar questions/answers without success I'll try to explain my situation.
I've an Andorid game developed with LibGDX, which also uses the Google Play Games services.
My game is composed by several projects:
google-play-services_lib (lib project provided by Google, unmodified)
http://i.stack.imgur.com/1XnHn.png (libs)
http://i.stack.imgur.com/Gay5H.png (buildpath)
BaseGameUtils (lib project provided by Google, unmodified. depends on 1)
http://i.stack.imgur.com/3iJ0W.png (libs)
http://i.stack.imgur.com/noNDX.png (buildpath)
odd-blocks (the principal project of the game)
http://i.stack.imgur.com/atsKA.png (libs)
http://i.stack.imgur.com/5MDua.png (buildpath)
odd-blocks-android (basically the main activity class, depends on 1, 2, and 3)
http://i.stack.imgur.com/VUxJt.png (libs)
http://i.stack.imgur.com/yP6wv.png (buildpath)
odd-blocks-desktop (for testing the game on desktop mode, depends on 3)
http://i.stack.imgur.com/pKGUf.png (libs)
http://i.stack.imgur.com/9XzdM.png (buildpath)
My problem is that, with the configuration shown, when I try to execute the odd-blocks-android project I obtain the following error:
[2014-03-08 19:04:22 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
[2014-03-08 19:04:22 - odd-blocks-andorid] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl;
Which is related to the "andorid-support-v4.jar", I'm sure to have only one version of this jar, as you can see in the images. There is a "solution" proposed in some questions to disable the private libraries in the build path configuration. In my case, if I do that, the game is executed but before starting there is a exception that says:
03-08 18:26:05.524: E/AndroidRuntime(15449): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.damsoft.oddblocks/com.damsoft.oddblocks.MainActivity}: java.lang.NullPointerException
There are also, some questions available about this second error message, that mentions that it is because the manifest is incorrect because does not have the activity registered. I'm sure that this is not my case, because I checked it, and also because my game worked before. In these questions they also mention that a way to resolve this error is to enable the "android private libraries" in the build path configuration screen, but then, I got the first error...
It is also important to mention that this error started to happen after the update to "Android SDK build-tools" v19 (currently 19.0.3).
I've been trying many things but nothing seems to solve the issue, maybe is something stupid... I don't know, but I'm out of ideas. I hope you can help :)
Finally I found the problem.
It was the "gdx-backend-android.jar", and some bad luck.
I installed a nightly build of LibGDX that for some reason included the classes of the android-support-v4.jar that caused the conflict of versions.
My solution was as simple as re-download libgdx.
But as a general remark, it is important to notice that this error message could mean that some other lib includes duplicated classes. Not necessarily with the same file name. The only way I found to check this was to rename the jar files to zip, and check for the duplicated class files.

Need help with using Saxon-B(version 9.1.0.8) with Java 1.4.2

I need to transform one XML document into another using XSLT (for now from command line). I have to use Java 1.4.2. Based on that someone recommended using Saxon and provided the XSLT. It seems simple it should work, but I am lost.
I come more form a .NET environment, and have worked with XML and XSLT but not with Saxon and I am not that strong in Java.
Let me start by explaining what my problem is and what I have tried so far:
The Error:
C:\Projects\new_saxon_download>java net.sf.saxon.Transform -s:source.xml -xsl:style.xsl -o:output.xml
Exception in thread "main" java.lang.NoClassDefFoundError: org/xml/sax/ext/DefaultHandler2
at net.sf.saxon.Configuration.(Configuration.java:2047)
at net.sf.saxon.Transform.setFactoryConfiguration(Transform.java:81)
at net.sf.saxon.Transform.doTransform(Transform.java:133)
at net.sf.saxon.Transform.main(Transform.java:66)
Steps that led me here:
I downloaded Saxon-B by following a link from this page
I also found some information on a dependency about SAX2 from this
page and thus obtained that as well.
Set the CLASSPATH in my session:
set CLASSPATH=.;C:\Projects\new_saxon_download\saxon9.jar;C:\Projects\new_saxon_download\sax2r2.jar
Tried the transformation:
java net.sf.saxon.Transform -s:source.xml -xsl:style.xsl -o:output.xml
Then I get the error shown above. I have tried multiple google search, but nothing has helped.
Any advice or solution would be very helpful.
GOT IT - the description on how to fix the dependendcy issue is crap (sorry).
This file sax2r2.jar isn't the one you have to add to the classpath. It contains another jar (sax.jar) and that's the library you actually need. Just extract the sax2r2.jar and put sax.jar on the classpath, then it should work.
Give this a try: apache xml-commons includes xml-api.jar. I can't tell if this is usable with java 1.4.12 but it's worth a try.
Binary releases can be found here. Download one of the xml-commons-external archives, extract xml-api.jar and add that to your classpath.

Categories