Gms play-services-location address the mutable vulnerability In May 03, 2022

189 阅读1分钟

image.png 2022年5月3日,Google 对

com.google.android.gms:play-services-location

升级了版本至 18.0.2 ,并修复了mutable 问题,下面聊聊具体报错

1. 项目使用

Module build.gradle

android {
    defaultConfig {
        applicationId 'oo.xx.yy'
        minSdk 21
        targetSdk 31
        versionCode 100
        versionName "1.0.0"
    }
}

dependencies {
    /**
     * google location 定位
     * https://developers.google.cn/android/guides/setup#list-dependencies
     * https://developers.google.cn/location-context/
     */
    implementation "com.google.android.gms:play-services-location:17.0.0"
}

2. 运行环境 Android 12L

image.png

3. 报错信息

image.png

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 with inline replies or bubbles.

错误信息是由gms 内部报出来的。所以看下Google 是否解决了此问题,在什么时间点解决的即可。

4. 问题解决

Module build.gradle 升级gms版本即可

dependencies {
    /**
     * google location 定位
     * https://developers.google.cn/android/guides/setup#list-dependencies
     * https://developers.google.cn/location-context/
     */
    implementation 'com.google.android.gms:play-services-location:20.0.0'
}