2016-03-31 11 views
0

Ich bin in einigen Bibliotheken von Apache POI Ich hatte mehrere Probleme überwunden, aber bin jetzt auf dieser Fehlermeldung fest, wenn ich versuche, ausführen die App;Android Studio: Ausführung fehlgeschlagen für Task ': app: transformClassesWithDex'

> Information:Gradle tasks [:app:assembleDebug] 
:app:preBuild UP-TO-DATE 
:app:preDebugBuild UP-TO-DATE 
:app:checkDebugManifest 
:app:preReleaseBuild UP-TO-DATE 
:app:prepareComAndroidSupportAppcompatV72221Library UP-TO-DATE 
:app:prepareComAndroidSupportDesign2221Library UP-TO-DATE 
:app:prepareComAndroidSupportRecyclerviewV72221Library UP-TO-DATE 
:app:prepareComAndroidSupportSupportV42221Library UP-TO-DATE 
:app:prepareComBignerdranchAndroidExpandablerecyclerview103Library UP-TO-DATE 
:app:prepareComGithubTraexExpandablelayoutLibrary13Library UP-TO-DATE 
:app:prepareDebugDependencies 
:app:compileDebugAidl UP-TO-DATE 
:app:compileDebugRenderscript UP-TO-DATE 
:app:generateDebugBuildConfig UP-TO-DATE 
:app:generateDebugAssets UP-TO-DATE 
:app:mergeDebugAssets UP-TO-DATE 
:app:generateDebugResValues UP-TO-DATE 
:app:generateDebugResources UP-TO-DATE 
:app:mergeDebugResources UP-TO-DATE 
:app:processDebugManifest UP-TO-DATE 
:app:processDebugResources UP-TO-DATE 
:app:generateDebugSources UP-TO-DATE 
:app:compileDebugJavaWithJavac UP-TO-DATE 
:app:compileDebugNdk UP-TO-DATE 
:app:compileDebugSources UP-TO-DATE 
:app:transformClassesWithDexForDebug 
trouble processing "javax/xml/stream/events/StartElement.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 
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. 
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_77\bin\java.exe'' finished with non-zero exit value 1 
Information:BUILD FAILED 
Information:Total time: 23.816 secs 
Information:1 error 
Information:0 warnings 
Information:See complete output in console 

Dinge, die ich habe versucht:

  • Enabling Multidex mit JavaMaxHeapSize
  • Verschiedene Versionen meiner benötigten Bibliotheken
  • reinigen/Bauen 9000+ mal
  • die .java-Dateien verwenden (von Apache-Site) und sie zu den Abhängigkeiten hinzufügen
  • Deaktivieren Proguard (aus irgendeinem Grund)
  • Zurückgehen und Konfigurieren von JAVA_HOME + Pfad
  • Aktualisieren von Java (die versuchen, wieder auf 1.7 morgen zurück) und wahrscheinlich einige andere Sachen.

Hier ist meine build.gradle Datei ohne Fehler

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 22 
    buildToolsVersion "21.1.2" 

    packagingOptions { 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/license.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/notice.txt' 
    } 

    defaultConfig { 
     applicationId "com.example.justin.wordcreator" 
     minSdkVersion 21 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled = true 
    } 

    dexOptions { 
     javaMaxHeapSize "4g" 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(include: ['Parse-*.jar'], dir: 'libs') 
    compile 'com.android.support:support-v4:22.2.1' 
    compile 'com.android.support:appcompat-v7:22.2.1' 
    compile 'com.android.support:recyclerview-v7:22.2.1' 
    compile 'com.android.support:design:22.2.1' 
    compile 'com.bignerdranch.android:expandablerecyclerview:1.0.3' 
    compile 'com.github.traex.expandablelayout:library:1.3' 
    compile 'org.apache.poi:poi-scratchpad:3.14' 
    compile 'com.github.virtuald:curvesapi:1.03' 
    compile 'org.apache.poi:poi:3.14' 
    compile 'xmlbeans:xmlbeans:2.3.0' 
} 

Wenn es um diese drei Bibliotheken verengt (Im XMLBeans 2.3 verwenden möchte aber 2.6 zum Laufen bringen)

compile 'org.apache.xmlbeans:xmlbeans:2.6.0' 
compile 'org.apache.poi:poi-ooxml:3.14' 
compile 'org.apache.poi:poi-ooxml-schemas:3.14' 

Sobald ich einige oder alle von ihnen hinzufügen, bekomme ich diese Fehlermeldung.

+1

Haben Sie die lange Fehlermeldung gelesen, die mit "Nicht empfohlene oder falsche Verwendung einer Kernklasse (java. * Oder javax. *) Beginnt, wenn keine Core-Bibliothek erstellt wird"? –

Antwort

2

Es gibt einige Dinge, die brechen, wenn bare POI auf Android, z. Die XMLBeans-JAR-Datei enthält verbotene und duplizierte Klassen, wodurch die Android-Kompilierung fehlschlägt.

Werfen Sie einen Blick auf https://github.com/andruhon/android5xlsx, die angepasste JAR-Dateien zur Verfügung stellt, die Apache POI auf Android 5.x möglich zu machen scheinen.

+0

Danke für die Antwort, aber am Ende habe ich nur die Apache-Dateien heruntergeladen und sie alle zu den Abhängigkeiten hinzugefügt, ich bin zurück, wo ich vor Ewigkeiten gestartet habe, und das ist dieser Fehler "java.lang.NoClassDefFoundError: Fehlgeschlagene Auflösung von: Ljavax/xml/stream/XMLEventFactory; " – Jube

+1

Einige der Gläser enthalten "verbotene" Klassen aus dem Paket javax ...., Desktop-Javva ist es egal, aber der Android-Build schlägt fehl, also brauchen Sie etwas wie https://github.com/andruhon/android5xlsx wo das ist behoben. – centic

+0

kein Glück, ich habe die Bibliotheken zuvor ausgecheckt, sie sind auf xlsx (Excel) gerichtet. Ich habe zu anderen Bibliotheken einschließlich docxj4 (Android-Zweig) weitergegangen. Ich war wieder in der Nähe, hatte aber Probleme mit jaxb. Ich werde eine ausführlichere Frage stellen, die erklärt, was ich versucht habe und wohin ich als nächstes gehen soll (kurz davor, eine .xml-Kopie der Vorlage.doc mit einer Base-64-Klasse für Bilder zu bearbeiten: /). Trotzdem danke! Wenn Sie von anderen Bibliotheken wissen, könnte ich versuchen, einfach zu erstellen/Laden/Bearbeiten/Speichern von Word-Formaten in Android Ich bin ganz Ohr – Jube

Verwandte Themen