在我的Android項目中,我使用的庫很少。問題的關鍵是,當我加入一個新的,例如:資源項目activity_horizontal_margin已定義
compile(group: 'com.example', name: 'example_sdk', version: '+', ext: 'aar') {
transitive = true;
}
,並試圖構建項目,我從gradle這個獲得下輸出錯誤:
D:\AndroidStudioProject\MyProject\res\values-w820dp\dimens.xml Error:(2) Resource entry activity_horizontal_margin is already defined. D:\AndroidStudioProject\MyProject\build\intermediates\exploded-aar\com.example\example_sdk\3.2.7\res\values-w820dp-v13\values-w820dp-v13.xml Error:(2, 1) Originally defined here. Error:Execution failed for task ':processMyAppUniversalDebugResources'. com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'D:\Tools\Android_SDK\build-tools\23.0.1\aapt.exe'' finished with non-zero exit value 1
我的猜測是,在一些庫中,我們有默認的定義值-w820d/dimen.xml,它們是衝突的。但問題是如何合併它們,因爲關鍵是一樣的。
values-w820d/dimen.xml content :
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
當我重新命名activity_horizontal_margin
到activity_horizontal_margin_default
- 衝突解決我的項目,但衝突似乎與其他圖書館。 也許我可以添加一些gradle-override屬性或修改gradle腳本來忽略它?