skip to Main Content

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>'

6

Answers


  1. Chosen as BEST ANSWER

    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."


  2. 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'
    
    Login or Signup to reply.
  3. updating the Android Gradle plugin to 7.3.3 (gradle-7.3.3-bin.zip)

    things will be ok.

    Login or Signup to reply.
  4. 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 { }

    Login or Signup to reply.
  5. 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.

    Login or Signup to reply.
  6. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search