Cómo limpiar dependencias de Gradle en Android Studio?

He añadido dependencias a Gradle y después de eso no puedo construir mi aplicación. Incluso si limpio la caché Gradle no puedo hacer mi compilación. Recibo este mensaje de error en Android :

 trouble processing "javax/xml/stream/EventFilter.class": Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library. This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on. However, you might actually be trying to define a class in a core namespace, the source of which you may have taken, for example, from a non-Android virtual machine project. This will most assuredly not work. At a minimum, it jeopardizes the compatibility of your app with future versions of the platform. It is also often of questionable legality. If you really intend to build a core library -- which is only appropriate as part of creating a full virtual machine distribution, as opposed to compiling an application -- then use the "--core-library" option to suppress this error message. If you go ahead and use "--core-library" but are in fact building an application, then be forewarned that your application will still fail to build or run, at some point. Please be prepared for angry customers who find, for example, that your application ceases to function once they upgrade their operating system. You will be to blame for this problem. If you are legitimately using some code that happens to be in a core package, then the easiest safe alternative you have is to repackage that code. That is, move the classes in question into your own package namespace. This means that they will never be in conflict with core system classes. JarJar is a tool that may help you in this endeavor. If you find that you cannot do this, then that is an indication that the path you are on will ultimately lead to pain, suffering, grief, and lamentation. 1 error; aborting :app:preDexDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:preDexDebug'. > com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Applications/Android Studio.app/sdk/build-tools/21.0.2/dx --dex --output /Users/alex/AndroidStudioProjects/client-poc/app/build/intermediates/pre-dexed/debug/stax-api-1.0-2-423956290996cba5c5243bbc25620fb74a9a3abd.jar /Users/alex/.gradle/caches/modules-2/files-2.1/javax.xml.stream/stax-api/1.0-2/d6337b0de8b25e53e81b922352fbea9f9f57ba0b/stax-api-1.0-2.jar Error Code: 1 Output: trouble processing "javax/xml/stream/EventFilter.class": 

¿Cómo puedo limpiar Gradle para evitar este error?

ACTUALIZAR

Mi archivo de construcción

 apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.0.2" defaultConfig { applicationId "com.soft.android_client" minSdkVersion 19 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { runProguard false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } lintOptions { abortOnError false } } repositories { mavenCentral() } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile ('org.restlet.jee:org.restlet:2.3-M3') compile ('org.restlet.jee:org.restlet.ext.jackson:2.3-M3') compile ('org.restlet.jee:org.restlet.ext.jaxb:2.3-M3') compile ('org.restlet.jee:org.restlet.ext.xml:2.3-M3') } 

UPDATE2

Después de agregar

 dexOptions { preDexLibraries = false } 

recibí

  UNEXPECTED TOP-LEVEL ERROR: java.lang.AssertionError: com.android.dx.command.dexer.Main$StopProcessing at com.android.dx.command.dexer.Main.processAllFiles(Main.java:542) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:279) at com.android.dx.command.dexer.Main.run(Main.java:245) at com.android.dx.command.dexer.Main.main(Main.java:214) at com.android.dx.command.Main.main(Main.java:106) Error:com.android.dx.command.dexer.Main$StopProcessing at com.android.dx.command.dexer.Main.checkClassName(Main.java:785) at com.android.dx.command.dexer.Main.processClass(Main.java:697) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:82) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main$ParallelProcessor.call(Main.java:1600) at com.android.dx.command.dexer.Main$ParallelProcessor.call(Main.java:1590) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.internal.LoggedErrorException: Failed to run command: /Applications/Android Studio.app/sdk/build-tools/21.0.2/dx --dex --num-threads=4 --output /Users/alex/AndroidStudioProjects/client-poc/app/build/intermediates/dex/debug /Users/alex/AndroidStudioProjects/client-poc/app/build/intermediates/classes/debug /Users/alex/AndroidStudioProjects/client-poc/app/build/intermediates/dependency-cache/debug 

  Error Code: 3 Output: trouble processing "javax/xml/stream/EventFilter.class": Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library. This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on. However, you might actually be trying to define a class in a core namespace, the source of which you may have taken, for example, from a non-Android virtual machine project. This will most assuredly not work. At a minimum, it jeopardizes the compatibility of your app with future versions of the platform. It is also often of questionable legality. If you really intend to build a core library -- which is only appropriate as part of creating a full virtual machine distribution, as opposed to compiling an application -- then use the "--core-library" option to suppress this error message. If you go ahead and use "--core-library" but are in fact building an application, then be forewarned that your application will still fail to build or run, at some point. Please be prepared for angry customers who find, for example, that your application ceases to function once they upgrade their operating system. You will be to blame for this problem. If you are legitimately using some code that happens to be in a core package, then the easiest safe alternative you have is to repackage that code. That is, move the classes in question into your own package namespace. This means that they will never be in conflict with core system classes. JarJar is a tool that may help you in this endeavor. If you find that you cannot do this, then that is an indication that the path you are on will ultimately lead to pain, suffering, grief, and lamentation. trouble processing "javax/xml/bind/Binder.class": Ill-advised or mistaken usage of a core class (java.* or javax.*) when not building a core library. This is often due to inadvertently including a core library file in your application's project, when using an IDE (such as Eclipse). If you are sure you're not intentionally defining a core class, then this is the most likely explanation of what's going on. However, you might actually be trying to define a class in a core namespace, the source of which you may have taken, for example, from a non-Android virtual machine project. This will most assuredly not work. At a minimum, it jeopardizes the compatibility of your app with future versions of the platform. It is also often of questionable legality. If you really intend to build a core library -- which is only appropriate as part of creating a full virtual machine distribution, as opposed to compiling an application -- then use the "--core-library" option to suppress this error message. If you go ahead and use "--core-library" but are in fact building an application, then be forewarned that your application will still fail to build or run, at some point. Please be prepared for angry customers who find, for example, that your application ceases to function once they upgrade their operating system. You will be to blame for this problem. If you are legitimately using some code that happens to be in a core package, then the easiest safe alternative you have is to repackage that code. That is, move the classes in question into your own package namespace. This means that they will never be in conflict with core system classes. JarJar is a tool that may help you in this endeavor. If you find that you cannot do this, then that is an indication that the path you are on will ultimately lead to pain, suffering, grief, and lamentation. warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.DataHandler$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$1) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$2) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$3) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$4) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. warning: Ignoring InnerClasses attribute for an anonymous inner class (javax.activation.SecuritySupport$5) that doesn't come with an associated EnclosingMethod attribute. This class was probably produced by a compiler that did not target the modern .class file format. The recommended solution is to recompile the class from source, using an up-to-date compiler and without specifying any "-target" type options. The consequence of ignoring this warning is that reflective operations on this class will incorrectly indicate that it is *not* an inner class. UNEXPECTED TOP-LEVEL ERROR: java.lang.AssertionError: com.android.dx.command.dexer.Main$StopProcessing at com.android.dx.command.dexer.Main.processAllFiles(Main.java:542) at com.android.dx.command.dexer.Main.runMonoDex(Main.java:279) at com.android.dx.command.dexer.Main.run(Main.java:245) at com.android.dx.command.dexer.Main.main(Main.java:214) at com.android.dx.command.Main.main(Main.java:106) Caused by: com.android.dx.command.dexer.Main$StopProcessing at com.android.dx.command.dexer.Main.checkClassName(Main.java:785) at com.android.dx.command.dexer.Main.processClass(Main.java:697) at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673) at com.android.dx.command.dexer.Main.access$300(Main.java:82) at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602) at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284) at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166) at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144) at com.android.dx.command.dexer.Main$ParallelProcessor.call(Main.java:1600) at com.android.dx.command.dexer.Main$ParallelProcessor.call(Main.java:1590) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) 

Intente agregar el siguiente código dentro del bloque android{} :

  dexOptions { preDexLibraries = false } 

Incluye una biblioteca que no está diseñada para Android.

Las siguientes líneas son acerca de Restlet, edición de Java EE.

 compile ('org.restlet.jee:org.restlet:2.3-M3') compile ('org.restlet.jee:org.restlet.ext.jackson:2.3-M3') compile ('org.restlet.jee:org.restlet.ext.jaxb:2.3-M3') compile ('org.restlet.jee:org.restlet.ext.xml:2.3-M3') 

Leer esta documentación puede ayudarle a:

http://restlet.com/download/current#release=stable&edition=android&distribution=maven

Tendrás que configurar un repositorio personalizado para Restlet y luego solicitar la edición de Android en lugar de la edición de Java EE.

En primer lugar, cambie esto a su archivo Gradle:

 repositories { mavenCentral() maven { url "http://maven.restlet.com" } } 

A continuación, cambie sus dependencias para estos:

 compile ('org.restlet.android:org.restlet:2.3-M3') compile ('org.restlet.android:org.restlet.ext.jackson:2.3-M3') compile ('org.restlet.android:org.restlet.ext.jaxb:2.3-M3') compile ('org.restlet.android:org.restlet.ext.xml:2.3-M3') 

EDITAR

Usted dijo en comentarios que esto no resuelve el problema. Encontré más información sobre esta pregunta: Android Studio ignore –core-library flag

Debe añadir esto a su archivo Gradle:

 dexOptions { coreLibrary = true; } 
  • Cómo definir las propiedades comunes de android para todos los módulos usando gradle
  • Cómo FTP un archivo de una compilación de Android Gradle?
  • Android Studio ignorar --core-library flag
  • Anulación del prefijo del paquete de permisos GCM con Gradle
  • Configuración de Proguard para Android Support v4 22.2.0
  • ¿Cómo puedo hacer coincidir una revisión de Servicios de Google Play con una versión de instalación?
  • La compilación de Gradle falla al buscar los servicios de Google Play en Android Studio
  • Atributos de vista personalizada de Android que no funcionan después de cambiar a gradle
  • ¿Cómo conozco las propiedades de applicationVariants de android gradle plugin?
  • Android Studio 0.8.2 "La sincronización del proyecto Gradle falló."
  • Cómo cambiar la versión de herramientas de compilación en Android Studio
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.