Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException,androidexception

來源:互聯網
上載者:User

Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessException,androidexception
異常Log:

Error:Execution failed for task ‘:app:dexDebug’. 
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘/Library/……/java” finished with non-zero exit value 2

錯誤原因:

這個異常在Android Studio編譯啟動並執行時候出現,原因是項目中引用了重複的jar包,這可能是因為新引入的library module中有和主專案中重複引用的jar包,需要重點檢查 Android 相容包 support-v4 和 support-v7 包,還有一些常用的開源項目,例如Gson,Nineoldandroids…,這些常用的開源項目有可能在你引用的 library 項目中已經被引用過了。

解決辦法:

解決這個問題我們只需要刪除主專案中 libs 檔案夾中和 library中重複的部分即可,另外,我推薦大家改變將 jar 包放在 libs 目錄中的習慣,而使用 Gradle 構建,在 module 下的 build.gradle 目錄下將

dependencies {    compile files('libs/nineoldandroids-2.4.0.jar')}
  • 1
  • 2
  • 3

或

dependencies {    compile fileTree(dir: 'libs', include: ['*.jar'])}
  • 1
  • 2
  • 3

改為

dependencies {    compile 'com.nineoldandroids:library:2.4.0'}
  • 1
  • 2
  • 3

在參考連結中,我發現一個類似的異常

Error:Execution failed for task ‘:app:dexDebug’. 
> com.android.ide.common.internal.LoggedErrorException

出現這個錯誤是因為主專案和Library項目中都引用了 compile ‘com.nineoldandroids:library:2.4.0’ ,但我在最新的 Android Studio 1.3 Preview 和 Gradle 2.3中給主專案和Library項目進行了一次類比,卻沒有出現該異常,根據問題中給出了 build.gradle 檔案,這可能是因為使用了低版本Android Studio 或 Gradle 的緣故,所以大家最好還是在項目中檢查一下,library項目中已經引入的jar,library就不要再引入到主專案中了。

參考連結:

http://stackoverflow.com/questions/27675717/gradle-error-execution-failed-for-task-appdexdebug/27675841

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.