android 材料设计示例代码给出缺少资源错误

新手上路,请多包涵

我正在尝试运行从以下 https://github.com/material-components/material-components-android 获取的相同的 android 材料设计

但出现这些错误:

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

原文由 neerajt 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 1.7k
2 个回答

使用当前版本的android studio(从4.2更新到2021.2.1并使用推荐的gradle插件)后问题解决了

当我打开相同的缺陷时从 github 得到以下回复“您附加的错误消息说无法识别资源标签,这需要 AGP 7.2。您必须使用高于 1.7.0-alpha02 的版本,请确保您的应用程序使用所需的最低插件版本。”

原文由 neerajt 发布,翻译遵循 CC BY-SA 4.0 许可协议

升级到此版本时出现相同的错误

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

但工作正常

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

原文由 Supun Ayeshmantha 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题