引入MaterialDesign提示style attribute not found

1. 问题描述

旧项目改造时,引入implementation 'com.google.android.material:material:1.2.0-alpha02'时异常,报错如下:

  Output:  /Users/buqx/Geone_Project/SipSmartTravel/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:3334: error: style attribute 'android:attr/dialogCornerRadius' not found.
  /Users/buqx/Geone_Project/SipSmartTravel/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:15: error: resource android:attr/dialogCornerRadius not found.
  /Users/buqx/Geone_Project/SipSmartTravel/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values-v28/values-v28.xml:19: error: resource android:attr/dialogCornerRadius not found.
  /Users/buqx/Geone_Project/SipSmartTravel/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1003: error: resource android:attr/fontVariationSettings not found.
  /Users/buqx/Geone_Project/SipSmartTravel/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1003: error: resource android:attr/ttcIndex not found.
  /Users/buqx/Geone_Project/SipSmartTravel/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1218: error: resource android:attr/lineHeight not found.
  /Users/buqx/Geone_Project/SipSmartTravel/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1223: error: resource android:attr/lineHeight not found.
  /Users/buqx/Geone_Project/SipSmartTravel/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:1472: error: resource android:attr/textFontWeight not found.

2. 原因

旧项目没有迁移到AndroidX。而我引入的版本是implementation 'com.google.android.material:material:1.2.0-alpha02'

3. 解决方法

将旧项目迁移至AndroidX或者引入support design,需要注意的是support包版本较低时,会缺少一些Material Design组件。

implementation 'com.android.support:design:28.0.0-alpha1'

你可能感兴趣的:(引入MaterialDesign提示style attribute not found)