前言
引入公共库库(commonLib)时,出现如下异常,说实话,看不懂哈,就问谷歌了。
- Can't determine type for tag '<macro name="m3_comp_assist_chip_container_shape">?attr/shapeAppearanceCornerSmall</macro>'
正文
简单记录一下,方便自己查阅。
第一种
原因
因为commonLib/build.gradle中的appcompat版本比我应用版本高。
库
- implementation 'androidx.appcompat:appcompat:1.6.1'
应用
- implementation 'androidx.appcompat:appcompat:1.3.1'
解决方法
改成统一的就行,公共库也是我自己维护,这里就改低版本。验证OK
- implementation 'androidx.appcompat:appcompat:1.3.1'
第二种
这次是用Android Studio创建新模块出现问题。
下面是用的版本
- Android Studio Giraffe | 2022.3.1
- Build #AI-223.8836.35.2231.10406996, built on June 29, 2023
- Runtime version: 17.0.6+0-b2043.56-10027231 amd64
- VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
- Windows 7 6.1
- GC: G1 Young Generation, G1 Old Generation
- Memory: 1280M
- Cores: 4
- Registry:
- external.system.auto.import.disabled=true
- ide.text.editor.with.preview.show.floating.toolbar=false
新创建模块后也是提示
- Can't determine type for tag '<macro name="m3_comp_assist_chip_container_shape">?attr/shapeAppearanceCornerSmall</macro>'
其实两个问题的本质都是一样,模块/build.gradle中配置的版本太高了。
下面都是AS默认创建的
- implementation 'androidx.appcompat:appcompat:1.6.1'
- implementation 'com.google.android.material:material:1.8.0'
- implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
下面是我这边改的
第一步
- implementation 'androidx.appcompat:appcompat:1.4.1'
- implementation 'com.google.android.material:material:1.4.0'
- implementation 'androidx.appcompat:appcompat:1.3.0'
但material这个涉及主题样式,相关的也需要改一下。
第二步
修改目录: values/themes.xml
- <resources xmlns:tools="http://schemas.android.com/tools">
- <!-- Base application theme. -->
- <style name="Base.Theme.BiuMall" parent="Theme.Material3.DayNight.NoActionBar">
- <!-- Customize your light theme here. -->
- <!-- <item name="colorPrimary">@color/my_light_primary</item> -->
- </style>
-
- <style name="Theme.BiuMall" parent="Base.Theme.BiuMall" />
- </resources>
Material3是高版本的,我们配置的不支持这个,因此该为MaterialComponents
- <resources xmlns:tools="http://schemas.android.com/tools">
- <!-- Base application theme. -->
- <style name="Base.Theme.BiuMall" parent="Theme.MaterialComponents.DayNight.NoActionBar">
- <!-- Customize your light theme here. -->
- <!-- <item name="colorPrimary">@color/my_light_primary</item> -->
- </style>
-
- <style name="Theme.BiuMall" parent="Base.Theme.BiuMall" />
- </resources>
第三步
同样,夜模式主题也得修改。
修改目录: values-night/themes.xml
- <resources xmlns:tools="http://schemas.android.com/tools">
- <!-- Base application theme. -->
- <style name="Base.Theme.BiuMall" parent="Theme.Material3.DayNight.NoActionBar">
- <!-- Customize your dark theme here. -->
- <!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
- </style>
- </resources>
修改后
- <resources xmlns:tools="http://schemas.android.com/tools">
- <!-- Base application theme. -->
- <style name="Base.Theme.BiuMall" parent="Theme.MaterialComponents.DayNight.NoActionBar">
- <!-- Customize your dark theme here. -->
- <!-- <item name="colorPrimary">@color/my_dark_primary</item> -->
- </style>
- </resources>
参考文章
《》
© 版权声明