android studio 引用aar包 出現檔案衝突

來源:互聯網
上載者:User

標籤:oid   option   androi   解決   error   file   resource   apk   ngoptions   

 開發項目,多多少少都會引進一些第三方jar或者aar資源檔,方便開發個人化功能,但這樣就經常會出現包衝突、檔案衝突、重複匯入資源或者匯入倆個不同的包中包含有相同的檔案資源呢!後果導致編譯失敗,提示錯誤! 
下面就來加講解下我遇到問題及解決方案:

1. 檔案衝突檔案錯誤提示

       一般類似這樣的Error:Execution failed for task ‘:app:transformResourcesWithMergeJavaResForDebug’.> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okio/okio/pom.xml File1: C:\Users\WX_JIN.gradle\caches\modules-2\files-2.1\com.squareup.okio\okio\1.6.0\98476622f10715998eacf9240d6b479f12c66143\okio-1.6.0.jar File2: D:\Android\workspace\wxj\YK\app\build\intermediates\exploded-aar\YK\umenglibrary\unspecified\jars\classes.jar 
上面提示Duplicate files copied in APK META-INF/maven/com.squareup.okio/okio/pom.xml 
重複這個檔案,我們只要去掉一個或者忽略一個就行了 

解決方案

       在主專案中添加build->android->添加packagingOptions exclude 包含重複的檔案 

2. jar衝突衝突提示

解決方案

 
 
使用上面這種忽略掉重複的依賴包

android studio 引用aar包 出現檔案衝突

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.