我在一个包含大约6个软件包(android库项目)的项目中遇到构建错误,并且每当我尝试在Windows机器上构建它时,每个模块都包含大约10个模块(在Mac中正常工作)
在某种程度上,这种情况开始发生(之前没有发生过),我无法确切知道何时(我很少使用Windows,很多人都会在这些捆绑/模块上提交)
我得到大约170个错误,第一个错误是:
:bundle-module:processDebugResources
C:\project\trunk\project-bundle\bundle-module\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.2.1\res\values\values.xml:807:5-965:13: AAPT: Error parsing XML: not well-formed (invalid token)
C:\project\trunk\project-bundle\bundle-module\build\intermediates\res\merged\debug\values-hdpi-v4\values-hdpi-v4.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Base.Widget.AppCompat.DrawerArrowToggle.Common'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.2.1\res\values-hdpi-v4\values-hdpi-v4.xml:3:5-7:14: AAPT: No resource found that matches the given name: attr 'barLength'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.2.1\res\values-hdpi-v4\values-hdpi-v4.xml:3:5-7:14: AAPT: No resource found that matches the given name: attr 'drawableSize'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\exploded-aar\com.android.support\appcompat-v7\24.2.1\res\values-hdpi-v4\values-hdpi-v4.xml:3:5-7:14: AAPT: No resource found that matches the given name: attr 'gapBetweenBars'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\res\merged\debug\values-sw600dp-v13\values-sw600dp-v13.xml:20: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Base.Widget.Design.TabLayout'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\exploded-aar\com.android.support\design\24.2.1\res\values-sw600dp-v13\values-sw600dp-v13.xml:12:5-15:13: AAPT: No resource found that matches the given name: attr 'tabGravity'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\exploded-aar\com.android.support\design\24.2.1\res\values-sw600dp-v13\values-sw600dp-v13.xml:12:5-15:13: AAPT: No resource found that matches the given name: attr 'tabMode'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\res\merged\debug\values-land\values-land.xml:7: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Base.Widget.Design.TabLayout'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\exploded-aar\com.android.support\design\24.2.1\res\values-land\values-land.xml:3:5-6:13: AAPT: No resource found that matches the given name: attr 'tabGravity'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\exploded-aar\com.android.support\design\24.2.1\res\values-land\values-land.xml:3:5-6:13: AAPT: No resource found that matches the given name: attr 'tabMode'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\res\merged\debug\values-large-v4\values-large-v4.xml:10: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Base.Theme.AppCompat.Dialog.FixedSize'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\res\merged\debug\values-large-v4\values-large-v4.xml:11: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Base.Theme.AppCompat.Light.Dialog.FixedSize'.
C:\project\trunk\project-bundle\bundle-module\build\intermediates\res\merged\debug\values-night-v8\values-night-v8.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat'
......
......
我尝试的事情:
答案 0 :(得分:0)
好的,我的一位同事看到了这个问题,并找到了解决方案,所以我在这里发布。他指出,在我们的build.gradle中,我们有以下任务:
String updateStylesResourcesFromConfig(String resourcesTag) {
File jsonFile = file("bundle-module/build/intermediates/exploded-aar/com.company.product/config-bundle/${version}/assets/config/app/styles/android/styles.json")
println "bundle-module/build/intermediates/exploded-aar/com.company.product/config-bundle/${version}/assets/config/app/styles/android/styles.json"
if (jsonFile.exists() && !jsonFile.text.isEmpty()) {
println "Updating style file in ${resourcesTag} mode"
// Reading json file text
def jsonContent = new JsonSlurper().parseText(jsonFile.text)
if (!jsonContent.isEmpty()) {
//Applying JSON file content
def primaryColor = jsonContent.Variables.primaryColor
def secondaryColor = jsonContent.Variables.secondaryColor
def primaryTextColor = jsonContent.Variables.primaryTextColor
println "bundle-module/build/intermediates/res/merged/${resourcesTag.toLowerCase()}/values/values.xml"
File valuesXMLFile = file("bundle-module/build/intermediates/res/merged/${resourcesTag.toLowerCase()}/values/values.xml")
if (valuesXMLFile.exists()) {
def response = new XmlParser().parseText(valuesXMLFile.text)
response.color.each {
def value
switch (it.@name) {
case "primaryColor":
value = primaryColor
break
case "secondaryColor":
value = secondaryColor
break
case "primaryTextColor":
value = primaryTextColor
break
}
if (value != null) {
replaceColorValue(it, value)
}
}
valuesXMLFile.text = XmlUtil.serialize(response)
}
}
}
}
出于某种原因,在Windows上,这并没有按预期工作。