最近发现我们的应用程序不适合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。还是同样的问题。
我不知道从这里去哪里,但我一直得到这个错误,即使我找不到pendingIntent在我的任何代码或node_modules。任何帮助都是感激的!
最终以SDK 30为目标,并添加了以下内容来构建。Gradle要使用旧版本的一些依赖
Android app won't build——在依赖中指定的minCompileSdk (31) 's androidx.work:work-runtime:2.7.0-beta01
运行React Native App时出错