最近发现我们的应用程序不适用于 Android 12 用户。
所以我将 compileSdkVersion 和 buildToolsVersion 更新为 31 并最终构建它..
现在在构建它时会安装但在启动时崩溃。在 logcat 中,我发现以下内容:
2021-10-30 17:17:56.596 17563-17587/com.walkabout.app E/AndroidRuntime: FATAL EXCEPTION: pool-4-thread-1
Process: com.walkabout.app, PID: 17563
java.lang.IllegalArgumentException: com.walkabout.app: 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.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at androidx.work.impl.utils.ForceStopRunnable.getPendingIntent(ForceStopRunnable.java:273)
at androidx.work.impl.utils.ForceStopRunnable.isForceStopped(ForceStopRunnable.java:151)
at androidx.work.impl.utils.ForceStopRunnable.forceStopRunnable(ForceStopRunnable.java:171)
at androidx.work.impl.utils.ForceStopRunnable.run(ForceStopRunnable.java:102)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
我发现 2 个依赖项确实使用了 pendingIntent,所以我更新到最新版本但没有运气,仍然是同样的错误。
所以我只是删除了那些,然后在整个项目目录中搜索pendingIntent,但不存在。清理项目,npm install,npx react-native run-android。还是同样的问题。
我不确定从这里去哪里,但是即使我在我的任何代码或 node_modules 中都找不到pendingIntent,我仍然会收到该错误。任何帮助表示赞赏!