1

I'm trying to add spring-context to a project in Android Studio. I have to bring in Xerces so Spring can parse my context file correctly, but that leads to this error:

Execution failed for task ':app:preDexDebug'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_79\bin\java.exe'' finished with non-zero exit value 1

gradlew assembleDebug says the problem is:

trouble processing "javax/xml/XMLConstants.class"

and then adds a long, supercilious lecture about why compiling core libraries is a bad thing. Okay, so how do I fix this?

One thing that didn't work was trying to exclude the offending module:

compile ('xerces:xercesImpl:2.11.0') {
    exclude module: 'xml-apis'
}

This led to much more extensive compile errors.

Another thing that didn't work was following the instructions for this Gradle JarJar plugin, which led to:

Could not find property 'preBuild' on task set.

I'm about ready to give up and just write my own parser from scratch. Is there a way to make this work?

pravn
  • 13
  • 3

1 Answers1

0

Xerces extends the core library javax which leads to this problem in Android.

You can overcome this problem by repackaging the needed classes with a tool like JarJar. This has been done in the Xerces-for-Android, wherein the package mf is placed above the "normal" Xerces packages.

Community
  • 1
  • 1
Petterson
  • 831
  • 9
  • 21