只要我的目标更新SDK至30(安卓R),棉绒警告Missing PendingIntent mutability flag出现在我的PendingIntent.FLAG_UPDATE_CURRENT标志时,我想定义PendingIntent。
我应该如何处理这个 lint 而不影响应用程序功能?
使用 Android Studio 4.2.1,在我的 build.gradle 文件中将 sdk 目标更改为 Android 12 后,出现Manifest merger failed with multiple errors, see logs错误。
Merged Manifest选项卡中显示的错误如下:
Merging Errors:
Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details. My_App.app main manifest (this file)
Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的应用程序更新到 Android SDK 31,但我遇到了 MediaSessionCompat 问题。
我有一个扩展 MediaBrowserServiceCompat() 的 MediaService,并在该服务的 onCreate 方法中初始化 MediaSessionCompat。
override fun onCreate() {
super.onCreate()
mediaSession = MediaSessionCompat(this, TAG).apply {
setCallback(mediaSessionCallback)
isActive = true
}
...
Run Code Online (Sandbox Code Playgroud)
但我有以下错误
java.lang.RuntimeException: Unable to create service com.radio.core.service.MediaService: java.lang.IllegalArgumentException: com.xxx.xxx: 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 …Run Code Online (Sandbox Code Playgroud)