title: Problem with Proguard and XmlPullParser
body: <p>I'm having a bit of trouble on an Android project using Proguard with some libraries. Specifically, i'm having an XmlPullParser collision, and no matter what i seem to do, i can't seem to solve it. Here are the libraries I am using:</p>
  
  <p><strong>JacksonParser, includes:</strong></p>
  
  <ul>
  <li>Jackson-all.1.6.4.jar</li>
  <li>Joda-time.1.6.2.jar</li>
  <li>jsr311-api-1.0.jar</li>
  <li>stax2-api-3.0.0.jar</li>
  </ul>
  
  <p><strong>XStream, which includes</strong>:</p>
  
  <ul>
  <li>xpp3_min-1.1.4c.jar</li>
  <li>xstream-for-android-1.0.0.jar</li>
  </ul>
  
  <p>There are also others, but they're a non-issue. These seem to be the culprit of our problems.</p>
  
  <p>Specifically, the issues are:</p>
  
  <p><strong>Optimization</strong></p>
  
  <p>if i do an optimization, i get "conversion to dalvik failed with 1". There is a post specifically about this at <a href="https://stackoverflow.com/questions/2680827/conversion-to-dalvik-format-failed-with-error-1-on-external-jar">&quot;Conversion to Dalvik format failed with error 1&quot; on external JAR</a>, which pointed me in the direction of having a duplicate XmlPullParser class. This makes sense, since XStream uses app3_min-1.1.4c.jar, which includes an XmlPullParser that has better/additional functionality than the one included in the android.jar. as such, i've tried a wildcard xmlpull** removal from android.jar:</p>
  
  <pre><code>-libraryjars &lt;java.home&gt;/lib/rt.jar;C:/Android/platforms/android-9/android.jar(!org/xmlpull/v1/**)
  </code></pre>
  
  <p>and i've also tried explicitly removing them:</p>
  
  <pre><code>-libraryjars &lt;java.home&gt;/lib/rt.jar;C:/Android/platforms/android-9/android.jar(!org/xmlpull/v1/XmlPullParser.class,!org/xmlpull/v1/XmlPullParserException.class,!org/xmlpull/v1/XmlPullParserFactory,!org/xmlpull/mxp1/MXParser)
  </code></pre>
  
  <p>but neither fix has helped.</p>
  
  <p>but wait, there's more (all centered around the same issue though, so i think if i solve this one, the others go away).</p>
  
  <p><strong>Obfuscation</strong></p>
  
  <p>If i try to obfuscate, i get the following runtime error:</p>
  
  <pre><code>java.lang.NoSuchMethodError: android.content.res.XmlResourceParser.s
  looking this up in the mapping, i get: .s = abstract int next()
  </code></pre>
  
  <p>so it's missing the next() method. so why is that method missing? i don't understand. i even tried doing this:</p>
  
  <pre><code>-keep class android.content.res.XmlResourceParser { int next(); }
  </code></pre>
  
  <p>to make sure that method gets preserved, but still i get the same issue.</p>
  
  <p><strong>Shrinking</strong></p>
  
  <p>Shrinking also seems to fail. the app launches but never gets anywhere, it just keeps trying to launch the first activity over and over and giving me a useless error. i'm not so worried about this yet though, i can live without shrinking, if i can get obfuscation and optimization working.</p>
  
  <p><strong>More Info</strong></p>
  
  <p>As a point of reference, i've tried to reference my libraries two ways, the first is using injars:</p>
  
  <pre><code>-injars ReferencedAssemblies/XStream/xpp3_min-1.1.4c.jar(!META-INF/MANIFEST.MF)
  -injars ReferencedAssemblies/JacksonParser/jackson-all-1.6.4.jar(!META-INF/MANIFEST.MF,!META-INF/ASL2.0,!META-INF/LICENSE,!META-INF/NOTICE)
  -injars ReferencedAssemblies/JacksonParser/joda-time-1.6.2.jar(!META-INF/MANIFEST.MF)
  -injars ReferencedAssemblies/JacksonParser/jsr311-api-1.0.jar(!META-INF/MANIFEST.MF)
  -injars ReferencedAssemblies/JacksonParser/stax2-api-3.0.0.jar(!META-INF/MANIFEST.MF)
  -injars ReferencedAssemblies/XStream/xstream-for-android-1.0.0.jar(!META-INF/MANIFEST.MF)
  </code></pre>
  
  <p>this won't even build.</p>
  
  <p>i've also done this:</p>
  
  <pre><code>-libraryjars &lt;java.home&gt;/lib/rt.jar
    ;C:/Android/platforms/android-9/android.jar(!org/xmlpull/v1/**)
    #;C:/Android/platforms/android-9/android.jar(!org/xmlpull/v1/XmlPullParser.class,!org/xmlpull/v1/XmlPullParserException.class,!org/xmlpull/v1/XmlPullParserFactory,!org/xmlpull/mxp1/MXParser)
    ;ReferencedAssemblies/JacksonParser/jackson-all-1.6.4.jar(!META-INF/MANIFEST.MF,!META-INF/ASL2.0,!META-INF/LICENSE,!META-INF/NOTICE)
    ;ReferencedAssemblies/JacksonParser/joda-time-1.6.2.jar(!META-INF/MANIFEST.MF)
    ;ReferencedAssemblies/JacksonParser/jsr311-api-1.0.jar(!META-INF/MANIFEST.MF)
    ;ReferencedAssemblies/JacksonParser/stax2-api-3.0.0.jar(!META-INF/MANIFEST.MF)
    ;ReferencedAssemblies/XStream/xpp3_min-1.1.4c.jar(!META-INF/MANIFEST.MF)
  </code></pre>
  
  <p>this gets me the furthest, i'm able to export an APK if i don't optimize. </p>
  
  <p>i've also done this:</p>
  
  <pre><code>-dontwarn org.xmlpull.v1.**
  </code></pre>
  
  <p>since this seems to be a known issue (see previous link)</p>
  
  <p>Anyone have any idea of what's going on here or how i solve it? i have a feeling that this has something to do with the fact that i'm using both XStream and JacksonParser, and perhaps one of the JacksonParser libraries also has an XmlPullParser in it? The thing is, that would explain the optimization error, but not the obfuscation error. i have no idea on that one. why would it not be finding that method, <em>even</em> if i've explicitly preserved it?</p>
  
  <p>thanks all.</p>