17

I am trying to run android material design same taken from below https://github.com/material-components/material-components-android

but getting these errors :

failed
:lib:packageDebugResources
tokens.xml
Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_sys_color_dark_surface_tint">?attr/colorPrimary</macro>'
fab_tokens.xml
Can't determine type for tag '<macro name="m3_comp_fab_primary_container_color">?attr/colorPrimaryContainer</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_comp_switch_selected_icon_color">?attr/colorOnPrimaryContainer</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_sys_motion_path">linear</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_sys_shape_corner_full_family">rounded</macro>'
tokens.xml
Can't determine type for tag '<macro name="m3_ref_typeface_brand_regular">sans-serif</macro>'
/Users/mac/AndroidStudioProjects/material-components-android/lib/java/com/google/android/material/bottomappbar/res/values/tokens.xml: Error: Can't determine type for tag '<macro name="m3_comp_bottom_app_bar_container_color">?attr/colorSurface</macro>'
Martin Zeitler
  • 1
  • 19
  • 155
  • 216
neerajt
  • 391
  • 1
  • 2
  • 11
  • Does this answer your question? [Can't determine type for tag '?attr/colorSurface'](https://stackoverflow.com/questions/74191324/cant-determine-type-for-tag-macro-name-m3-comp-bottom-app-bar-container-colo) – Edric Jul 07 '23 at 15:30

6 Answers6

28

I got the same error when upgrade to this version

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.8.0-alpha01'

But working fine in

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'
Supun Ayeshmantha
  • 499
  • 1
  • 5
  • 9
11

Problem is solve after using current version of android studio ( updated from 4.2 to 2021.2.1 and used recommended gradle plugin )

Got the below reply from github when i open defect for same "The error message you attached says not recognizing resource tag, which requires AGP 7.2. You must use a version later than 1.7.0-alpha02, please make sure your app build with the minimum required plugin versions."

neerajt
  • 391
  • 1
  • 2
  • 11
3

Replace :

implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'

with:

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.6.0'

in build.gradle(:app) file under dependencies { }

user3673952
  • 698
  • 10
  • 30
2

updating the Android Gradle plugin to 7.3.3 (gradle-7.3.3-bin.zip)

things will be ok.

sodino
  • 261
  • 3
  • 5
1

Try downgrading material design library in build.gradle(app).

I have changed

implementation 'com.google.android.material:material:1.7.0'

to

implementation 'com.google.android.material:material:1.6.0'

And this resolved my issue.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Aishwarya
  • 151
  • 1
  • 5
0

This issue should be relevant to people who dig deeper and do not directly work with these dependencies, as it works fine for building and running apps in Android Studio.

It seems that material 1.7.0 is using illegal tag <macro>, you can see it in multiple files when looking through their release changes, specifically the **/tokens.xmlfiles. I could not find any information about this tag in AGP documentation and the only references to it I found from this git repo was this part of the code

private fun parseMacro(
    element: StartElement, eventReader: XMLEventReader, parsedResource: ParsedResource): Boolean {
...
  // Macros can only be defined in the default config
  val defaultConfig = ConfigDescription()
  if (parsedResource.config != defaultConfig) {
    logError(
      blameSource(source, element.location),
      "<macro> tags cannot be declared in configurations other than the default configuration")
      return false
    }

So I'm not really sure how did they work around it. In the future it is possible that AGP will support this tag externally and include it in their documentation, but for now you'll have to use workarounds

Eivyses
  • 341
  • 1
  • 5
  • 13