前言
????????今天就来整理一下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);
|