Convert dalvik to Android for xmlpullparser

I am developing an application for Android, and for one component I can test outside of Android, since it does not use any Android codes.

It uses xstream, and I have the following libraries: xstream1.4.6 xpp3-min-1.1.4c xmlpull-1.1.3.1

When I unit test my code outside of Android, everything works fine.

When I try to use it with Android, I get the following error:

[2014-01-15 18:59:23 - Dex Loader] Unable to execute dex: Multiple dex files define Lorg/xmlpull/v1/XmlPullParser; [2014-01-15 18:59:23 - AndroidMentor] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lorg/xmlpull/v1/XmlPullParser; 

This is a clean brand new android app android android junit. I tried to remove garbage, clean, etc., but not to use. This is just this one, others do not show any problems.

I need this pullparser as others do not seem to work with xstream for me.

+4
android dex xmlpullparser
source share
1 answer

I had the same problem with a separately developed project that I was trying to integrate with an Android application. The problem is that the Android API defines the XmlPullParser class ( https://developer.android.com/reference/org/xmlpull/v1/XmlPullParser.html ), which is why this conflict occurs.

I solved the problem by eliminating the xmlpull dependency on the project, which allowed the use of the version of classes defined by Android. This is how my build.gradle file looks for an application module (just a dependency section to illustrate the exception):

 dependencies { compile (project(':epublib:epublib-core')) { exclude group: 'xmlpull' } compile 'com.android.support:appcompat-v7:21.0.+' compile 'com.android.support:support-v4:21.0.+' } 

The syntax is important. It should have the form

 compile (project(':project-name')) { exclude group: 'group-name', module: 'module-name' } 
+2
source share

All Articles