More than one file was found with OS independent path 'AndroidManifest.xml

More than one file was found with OS independent path 'AndroidManifest.xml'

AGP升級 3.5.0+

你組件化項目升級由原本的gradle 插件版本 3.4.2 升級到了 3.5.3, 執行assembleRelease。的時候報了一個錯誤:
More than one file was found with OS independent path ‘AndroidManifest.xml’

修復

做了很多各方面的分析, 依然不得解. 因爲我降低到 3.4.2 的時候, assembleRelease是正常的.

這裏也有遇到了相同的問題,升級 AGP遇到的問題

得知的是一個 bug. 去查了一下: Google Issue Tracker

得出的結論就是:

換成 module 形式進行依賴或者打包上傳到 maven 私服進行依賴

果然試了一下, 確實兩種方式都有效.

組件化排查此類問題

What went wrong:
Execution failed for task ‘:module_name:mergeReleaseJavaResource’.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
More than one file was found with OS independent path ‘AndroidManifest.xml’

可以根據 module_name 對依賴的本地 aar 進行處理

類似的錯誤

What went wrong:
Execution failed for task ‘:module_name:mergeReleaseJavaResource’.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
More than one file was found with OS independent path ‘res/values/values.xml’

res/values/values.xml這個錯誤是組件化項目合併的時候資源有衝突.
大部分是資源命名錯誤導致. 對項目很熟悉的開發人員, 可能不會去添加 module 資源前綴,但是最好加上, 因爲有可能添加了 color 或者 string 等的時候, 名字重複, 那麼就會報這個錯誤.

就是方式就是排查出基礎 module和其他依賴的 module 資源命名是否有衝突.
或者 module 的 build.gradle 裏面都加resourcePrefix

android {
    ......
    defaultConfig {
    ......
        resourcePrefix 'xxxxxx'
    }
    ....
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章