Hye*_*ung 5 android kotlin firebase
我使用科特林语言。
我一直面临这个未决的意图错误。
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
Run Code Online (Sandbox Code Playgroud)
但是当我在项目中搜索待定意图时,我PendingIntent根本没有使用过。
这个错误提一下GlobalApplication.kt:17。
在全球应用程序中:
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!!
}
}
Run Code Online (Sandbox Code Playgroud)
没有 PendingIntent。
有人说将其设置为以下依赖项build.gradle(:app)
implementation 'androidx.work:work-runtime-ktx:2.7.0'
Run Code Online (Sandbox Code Playgroud)
所以我这样做了,但仍然有这个错误..
我怎样才能解决这个问题?
我试图运行前台服务,但遇到了类似的问题。
我用来PendingIntent通知用户有关前台服务的信息
我已将最后一个参数中的标志值从0更改为PendingIntent.FLAG_IMMUTABL E,并且在我的情况下已解决。
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 1, intent, 0);
Run Code Online (Sandbox Code Playgroud)
用这个代替
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 1, intent, PendingIntent.FLAG_IMMUTABLE);
Run Code Online (Sandbox Code Playgroud)
我希望这个答案能有所帮助
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)
Run Code Online (Sandbox Code Playgroud)
这里有两种可能性。
一是您的应用程序是com.chugnchunon.chungchunon_android(请参阅堆栈跟踪片段的底行)。如果是这样,则您正在使用com.kakao.auth.KakaoSDK(请参阅堆栈跟踪片段的倒数第二行),并且它是创建损坏的PendingIntent. 您将需要更新您的应用程序以使用包含该类的较新版本的库KakaoSDK,或者联系其开发人员并指出问题。
另一个是它com.chugnchunon.chungchunon_android.GlobalApplication本身来自一个库,并且它正在使用KakaoSDK. 在这种情况下,您将需要升级到包含该类的库的较新版本com.chugnchunon.chungchunon_android.GlobalApplication,或者联系其开发人员并指出问题。
| 归档时间: |
|
| 查看次数: |
7108 次 |
| 最近记录: |