Android项目升级到Android12报错集合

前言

        今天就来整理一下Android11项目升级Android12遇到的问题,不得不说比起之前的升级问题多多了,小伙伴是否遇到相同的问题了呢?



错误1

Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present'

解决方法

所有activity,receiver,service等, 带有intent-filter标签的节点必须添加exported属性

对外部APP开放,设置为true,APP的启动Activity必须设置为exported="true"否则启动app时找不到Activity

exported=“true”

只在APP内部使用,设置为false

exported=“false”

<activity 
   android:exported="true">
    <intent-filter>
        <!-------->
    </intent-filter>
</activity>

错误2

Package: xxxx attempting to declare permission xxxx.andpermission.bridge in non-existing group xxxx.andpermission

解决方法

在AndroidManifest.xml文件manifest节点下添加

<manifest>
    <!-------->
    <permission-group android:name="${applicationId}.andpermission"/>

</manifest>

错误3

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used

解决方法

在创建或使用时PendingIntent的flags参数必须添加 FLAG_IMMUTABLE,
FLAG_MUTABLE,两个之中其中一个,官方推荐添加:FLAG_IMMUTABLE
,看个人需求

PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
  • 10
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Felix_Fly2021

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值