Can't determine type for tag

Android  2023年9月7日 pm6:42发布1年前 (2023)更新 91es.com站长
61 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. 2022: 系统应用MediaButton的使用方式(0条评论)
  2. 2021: DisplayMetrics获取宽高不对(0条评论)
  3. 2019: 贾平凹:制造声音(0条评论)
版权声明 1、 本站名称: 91易搜
2、 本站网址: 91es.com3xcn.com
3、 本站内容: 部分来源于网络,仅供学习和参考,若侵权请留言
3、 本站申明: 个人流水账日记,内容并不保证有效

暂无评论

暂无评论...

随机推荐

Android之Back键和HOME键拦截处理

一、拦截BACK键一般的应用有两种方法可以获取,当然你也可以修改Framework层代码进行拦截,但这个真的没必要修改。方法1、重写Activity的onKeyDown方法@Overridepublic boolean onKeyDown(int keyCode, KeyEvent...

林徽因:笑

笑的是她的眼睛,口唇,和唇边浑圆的旋涡。艳丽如同露珠,朵朵的笑向贝齿的闪光里躲。那是笑——神的笑,美的笑;水的映影,风的轻歌。 笑的是她惺松的鬈发,散乱的挨着她的耳朵。轻软如同花影,痒痒的甜蜜涌进了你的心窝。那是笑——诗的笑,画的笑:云的留痕,浪的柔波。选自《...

茅盾:白杨礼赞

白杨树实在是不平凡的,我赞美白杨树!当汽车在望不到边际的高原上奔驰,扑入你的视野的,是黄绿错综的一条大毡子;黄的,那是土,未开垦的处女土,几十万年前由伟大的自然力所堆积成功的黄土高原的外壳;绿的呢,是人类劳力战胜自然的成果,是麦田,和风吹送,翻起了一轮一轮的绿波——,这时你会真心佩服昔人所造的两个...

胡适:赠与今年的大学毕业生

这一两个星期里,各地的大学都有毕业的班次,都有很多的毕业生离开学校去开始他们的成人事业。学生的生活是一种享有特殊优待的生活,不妨幼稚一点,不妨吵吵闹闹,社会都能纵容他们,不肯严格的要他们负行为的责任。现在他们要撑起自己的肩膀来挑他们自己的担子了。在这个国难最紧急的年头,他们的担子真不轻! 我们祝他们...

Zygote的启动之一app_main

前言Android系统中,所有的应用程序以及SystemServer都是由Zygote进程孕育(fork)出来的。这里介绍app_main.cpp中的代码。Android P正文涉及文件\system\core\rootdir\init.rc\system\core\rootdir...

Launcher2导入Eclipse

在分析源码中,除了使用Source Insight 这个强大的软件外,有些应用还是用编译器看源码是最好的,因此今天我们学习一下如何导入源码到Eclipse中。这里主要是讲正确把Android 6.0 的Launcher2 导入Eclipse中并运行和安装应用。工具: Eclipse,L...