Unsupported type 'add-resource' in Android

2019-07-01 19:19发布

问题:

I encountered a resource merging issue when running a gradle build command.

Logs as below:

Error:Execution failed for task ':frameworks:base:core:res:res-common:packageReleaseResources'.> Unsupported type 'add-resource' in file .../kk4_4/frameworks/base/core/res/res-common/res/values-XXX/dimens.xml

Environment:

  • Android Studio: 0.5.8
  • Android Plugin: 0.10.+
  • Gradle Version: all damned from 1.10 to 1.12

Resource:

<add-resource type="dimen" name="slidingmenu_menu_width"/>
<dimen name="slidingmenu_menu_width">232dip</dimen>

<add-resource type="dimen" name="card_list_item_padding_left" />
<dimen name="card_list_item_padding_left">13.5dip</dimen>

These <add-resource /> nodes are used for overlays in aapt, and I wonder if there's a way to pass gradle builds without removing them?

回答1:

I've solved this problem myself, here is the result: add-resource node is not supported when using android plugin 0.8.+ or later If we change

dependencies {
    classpath 'com.android.tools.build:gradle:0.9.+'
}

to

dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
}

and use gradle 1.8 instead of the later versions

run gradle tasks in terminal, and all tasks turn to success

but the 'Gradle Sync' function will not work properly in the latest Android Studio,

Hope google deals with it soon.