Skip to content

SdlRouterService crashes if SDL app sets targetSdkVersion to 31, and running on Android 12 #1751

@shiniwat

Description

@shiniwat

Bug Report

SdlRouterService causes crash if the SDL app sets targetSdkVersion to 31, and running on Android 12.

Reproduction Steps
  1. open app's build.gradle, and change targetSdkVersion to 31.
  2. build the app, and run on Android 12 beta 5 device
Expected Behavior

The app should run normally even if the app's targetSdkVersion is 31. Please note that sdl_java_suite library's targetSdkVersion (which is 30 in release/5.3.0_RC branch) will be overridden by app's targetSdkVersion.

Observed Behavior

The app crashes by fatal exception below:

    E/AndroidRuntime: FATAL EXCEPTION: main
    ... <snip>
     Caused by: java.lang.IllegalArgumentException: net.shiniwa.mytestapp: 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.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
        at android.app.PendingIntent.getActivity(PendingIntent.java:444)
        at android.app.PendingIntent.getActivity(PendingIntent.java:408)
        at com.smartdevicelink.transport.SdlRouterService.enterForeground(SdlRouterService.java:1524)
        at com.smartdevicelink.transport.SdlRouterService.onCreate(SdlRouterService.java:1142)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:4491)
OS & Version Information
  • Android Version: Android 12 beta 5 (SPB5.210812.002)
  • SDL Android Version: release/5.3.0_RC branch (commit #60230823b341eb9e2e95f2c0649a322c7d5b9db1)
  • Testing Against: the crash has nothing to do with head unit, but you have to at least setup bluetooth pairing with head unit.
Test Case, Sample Code, and / or Example App

PR will be submitted later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA defect in the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions