Can't determine type for tag

Android2023年9月7日 pm6:42发布11个月前更新 3XCN.COM站长
0 0 0
广告也精彩
目录

前言

引入公共库库(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>

参考文章

  1. 【Android studio错误处理】Can‘t determine type for tag ‘<macro name=“m3_comp_assist_chip_container_shape“>

 历史上的今天

版权声明 1、 本站名称: 91易搜
2、 本站网址: 91es.com3xcn.com
3、 本站文章: 部分来源于网络,仅供站长学习和参考,若侵权请留言
广告也精彩

相关文章

广告也精彩

暂无评论

评论审核已启用。您的评论可能需要一段时间后才能被显示。

暂无评论...

网站升级中

公告

近期网站升级中,可能存在一些bug。欢迎反馈 https://www.91es.com/we.html

本站域名

本站域名 : 91es.com3xcn.com。本站邮箱 : 站长邮箱 i@oorr.cn,通知邮箱we@oorr.cn ,如有更新,请看公告 。