skip to Main Content

I use kotlin language.

I keep facing this pending intent error.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.chugnchunon.chungchunon_android, PID: 20394
    java.lang.RuntimeException: Unable to create application com.chugnchunon.chungchunon_android.GlobalApplication: java.lang.IllegalArgumentException: com.chugnchunon.chungchunon_android: 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.ActivityThread.handleBindApplication(ActivityThread.java:6764)
        at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7872)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
     Caused by: java.lang.IllegalArgumentException: com.chugnchunon.chungchunon_android: 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:401)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:671)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:658)
        at com.kakao.auth.Session.<init>(Session.java:156)
        at com.kakao.auth.Session.initialize(Session.java:101)
        at com.kakao.auth.KakaoSDK.init(KakaoSDK.java:101)
        at com.chugnchunon.chungchunon_android.GlobalApplication.onCreate(GlobalApplication.kt:17)
        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1277)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6759)
            ... 9 more

but when I search pending intent in my project, I haven’t used PendingIntent at all.

this error mention GlobalApplication.kt:17.

in GlobalApplication :

package com.chugnchunon.chungchunon_android

import android.app.Application
import com.chugnchunon.chungchunon_android.Adapter.KakaoSDKAdapter
import com.kakao.auth.*

class GlobalApplication : Application() {
    companion object {
        var instance: GlobalApplication? = null
    }

    override fun onCreate() {
        super.onCreate()
        instance = this

        KakaoSDK.init(KakaoSDKAdapter(getAppContext()))
    }

    override fun onTerminate() {
        super.onTerminate()
        instance = null
    }

    fun getAppContext(): GlobalApplication {
        checkNotNull(instance) {
            "This Application does not inherit com.example.App"
        }
        return instance!!
    }
}

There’s no PendingIntent.

some people said to set this below dependency in build.gradle(:app)

implementation 'androidx.work:work-runtime-ktx:2.7.0'

So I did it but still I have this error..

How can I fix this?

2

Answers


  1.      Caused by: java.lang.IllegalArgumentException: com.chugnchunon.chungchunon_android: 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:401)
            at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:671)
            at android.app.PendingIntent.getBroadcast(PendingIntent.java:658)
            at com.kakao.auth.Session.<init>(Session.java:156)
            at com.kakao.auth.Session.initialize(Session.java:101)
            at com.kakao.auth.KakaoSDK.init(KakaoSDK.java:101)
            at com.chugnchunon.chungchunon_android.GlobalApplication.onCreate(GlobalApplication.kt:17)
    

    There are two possibilities here.

    One is that your app is com.chugnchunon.chungchunon_android (see the bottom line of the stack trace snippet). If so, you are using com.kakao.auth.KakaoSDK (see the second-to-bottom line of the stack trace snippet), and it is the one that is creating the broken PendingIntent. You will need to update your app to use a newer version of the library that contains that KakaoSDK class, or contact its developers and point out the problem.

    The other is that com.chugnchunon.chungchunon_android.GlobalApplication itself is from a library, and it is using KakaoSDK. In that case, you will need to upgrade to a newer version of the library that contains that com.chugnchunon.chungchunon_android.GlobalApplication class, or contact its developers and point out the problem.

    Login or Signup to reply.
  2. I was trying to run Foreground service and I had the similar issue.

    I was using PendingIntent to notify user about foreground service

    I have changed the flag value from 0 to PendingIntent.FLAG_IMMUTABLE in the last param and it was resolved in my case.

    PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 1, intent, 0);
    

    use this instead

    PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 1, intent, PendingIntent.FLAG_IMMUTABLE);
    

    I hope this answer will help

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search