2015-06-29 60 views
0

我正在嘗試將apache POI庫與我的android應用程序集成。爲此,我已經將apache poi jar文件添加到我的libs文件夾中,並使用「編譯文件」來編譯通過build.gradle。但是當我進行gradle同步時,它沒有問題。在進行gradle同步之後,當我嘗試運行應用程序時,我得到錯誤執行失敗的任務':app:preDexDebug'。任務':app:preDexDebug'的執行失敗。 > com.android.ide.common.process.ProcessException:

我見過以下類似的問題,但沒有用。

Error: Execution failed for task ':app:preDexDebug'

https://stackoverflow.com/questions/27437049/android-studio-gradle-execution-failed-for-task-apppredexdebug

以下是我gradle這個依賴:

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
compile 'com.android.support:appcompat-v7:22.1.1' 
compile files('libs/poi-3.12-20150511.jar') 
compile files('libs/poi-ooxml-3.12-20150511.jar') 
compile files('libs/poi-ooxml-schemas-3.12-20150511.jar') 
compile files('libs/xmlbeans-2.6.0.jar') 
} 

錯誤消息:

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.8.0_31\bin\java.exe'' 
    finished with non-zero exit value 1 

搖籃控制檯輸出:

:app:compileDebugNdk UP-TO-DATE 
:app:compileDebugSources 
:app:preDexDebug 
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"} 
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.XmlBeans$1) that doesn\u0027t come with an","position":{},"original":"(org.apache.xmlbeans.XmlBeans$1) that doesn\u0027t come with an"} 
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"} 
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"} 
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"} 
AGPBI: {"kind":"SIMPLE","text":"and without specifying any \"-target\" type options. The consequence of ignoring","position":{},"original":"and without specifying any \"-target\" type options. The consequence of ignoring"} 
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"} 
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."} 
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"} 
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.XmlSimpleList$1) that doesn\u0027t come with an","position":{},"original":"(org.apache.xmlbeans.XmlSimpleList$1) that doesn\u0027t come with an"} 
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"} 
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"} 
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"} 
AGPBI: {"kind":"SIMPLE","text":"and without specifying any \"-target\" type options. The consequence of ignoring","position":{},"original":"and without specifying any \"-target\" type options. The consequence of ignoring"} 
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"} 
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."} 
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"} 
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.XmlSimpleList$2) that doesn\u0027t come with an","position":{},"original":"(org.apache.xmlbeans.XmlSimpleList$2) that doesn\u0027t come with an"} 
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"} 
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"} 
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"} 
AGPBI: {"kind":"SIMPLE","text":"and without specifying any \"-target\" type options. The consequence of ignoring","position":{},"original":"and without specifying any \"-target\" type options. The consequence of ignoring"} 
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"} 
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."} 
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"} 
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$1) that doesn\u0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$1) that doesn\u0027t come with an"} 
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"} 
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"} 
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"} 
AGPBI: {"kind":"SIMPLE","text":"and without specifying any \"-target\" type options. The consequence of ignoring","position":{},"original":"and without specifying any \"-target\" type options. The consequence of ignoring"} 
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"} 
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."} 
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"} 
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$2) that doesn\u0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$2) that doesn\u0027t come with an"} 
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"} 
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"} 
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"} 
AGPBI: {"kind":"SIMPLE","text":"and without specifying any \"-target\" type options. The consequence of ignoring","position":{},"original":"and without specifying any \"-target\" type options. The consequence of ignoring"} 
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"} 
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."} 
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"} 
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$3) that doesn\u0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.regex.SchemaRegularExpression$3) that doesn\u0027t come with an"} 
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"} 
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"} 
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"} 
AGPBI: {"kind":"SIMPLE","text":"and without specifying any \"-target\" type options. The consequence of ignoring","position":{},"original":"and without specifying any \"-target\" type options. The consequence of ignoring"} 
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"} 
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."} 
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"} 
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$SchemaTypeLoaderCache$1) that doesn\u0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl$SchemaTypeLoaderCache$1) that doesn\u0027t come with an"} 
AGPBI: {"kind":"SIMPLE","text":"associated EnclosingMethod attribute. This class was probably produced by a","position":{},"original":"associated EnclosingMethod attribute. This class was probably produced by a"} 
AGPBI: {"kind":"SIMPLE","text":"compiler that did not target the modern .class file format. The recommended","position":{},"original":"compiler that did not target the modern .class file format. The recommended"} 
AGPBI: {"kind":"SIMPLE","text":"solution is to recompile the class from source, using an up-to-date compiler","position":{},"original":"solution is to recompile the class from source, using an up-to-date compiler"} 
AGPBI: {"kind":"SIMPLE","text":"and without specifying any \"-target\" type options. The consequence of ignoring","position":{},"original":"and without specifying any \"-target\" type options. The consequence of ignoring"} 
AGPBI: {"kind":"SIMPLE","text":"this warning is that reflective operations on this class will incorrectly","position":{},"original":"this warning is that reflective operations on this class will incorrectly"} 
AGPBI: {"kind":"SIMPLE","text":"indicate that it is *not* an inner class.","position":{},"original":"indicate that it is *not* an inner class."} 
AGPBI: {"kind":"SIMPLE","text":"warning: Ignoring InnerClasses attribute for an anonymous inner class","position":{},"original":"warning: Ignoring InnerClasses attribute for an anonymous inner class"} 
AGPBI: {"kind":"SIMPLE","text":"(org.apache.xmlbeans.impl.validator.ValidatingXMLInputStream$1) that doesn\u0027t come with an","position":{},"original":"(org.apache.xmlbeans.impl.validator.ValidatingXMLInputStream$1) that doesn\u0027t come with an"} 

失敗

失敗:建立失敗,一個例外。

  • 出了什麼問題: 執行失敗的任務 ':應用程序:preDexDebug'。

    com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_31\bin\java.exe'' finished with non-zero exit value 1

  • 嘗試: 與--stacktrace選項獲取堆棧跟蹤運行。使用--info或--debug選項運行以獲取更多日誌輸出。

構建失敗

總時間:22.982秒

+0

它發生是因爲衝突庫。當有一個庫使用兩次,你會得到錯誤。 –

+0

你可以看到我的依賴文件,我沒有使用任何庫兩次。 @MohammedImranN –

+1

你爲什麼不讓Gradle爲你下載這些庫?例如,爲poi庫使用以下代碼: compile'org.apache.poi:poi:3.12' 這將讓gradle管理依賴庫(可能是問題)。 您也可以使用gradle命令查看重複的庫。 gradlew依賴關係 – AndroidGuy

回答

0
  1. 你試試下面的序列(按順序):無效緩存&重啓=> gradle這個同步=> gradle這個乾淨= > gradle構建?

  2. 在File => Project Structure => SDK Location中:您是否將JDK位置設置爲指向JDK 7的有效安裝?

  3. 你在模塊的build.gradle這是觸發錯誤有這樣的:

    android { 
        ... 
        compileOptions { 
         sourceCompatibility JavaVersion.VERSION_1_7 
         targetCompatibility JavaVersion.VERSION_1_7 
        } 
    } 
    
+0

我試過乾淨的,失效的緩存和gradle同步。一切都很好,gradle同步是成功的。但是當試圖運行應用程序時,得到這個問題。 @ Phileo99 –

+0

不,我的build.gradle文件中沒有「compileOptions」模塊。 無論如何,我放棄使用Apache Poi庫來創建Excel文件。相反,我試着用「Aspose.jar」來解決我的問題。 –

相關問題