You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

适配Android 13(API 33)后Activity自动关闭问题求助

适配Android 13(API 33)时Activity首次启动后自动关闭异常

将ABC应用适配到Android 13(API level 33)时遇到异常:打开应用后点击按钮启动新Activity,启动成功后该Activity会在2-4秒内自动关闭,无报错信息且未触碰设备;但再次打开该Activity则能正常留存直至手动关闭。

Activity关闭前Logcat输出

DEBUG: elapsed 2 / 6
2023-03-27 20:58:20.352 24711-24763 FA                      com.my.package        V  Recording user engagement, ms: 4262
2023-03-27 20:58:20.390 24711-24711 DynamiteModule          com.my.package         I  Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:230500000
2023-03-27 20:58:20.390 24711-24711 DynamiteModule          com.my.package        I  Selected remote version of com.google.android.gms.ads.dynamite, version >= 230500000
2023-03-27 20:58:20.390 24711-24711 DynamiteModule          com.my.package         V  Dynamite loader version >= 2, using loadModule2NoCrashUtils
2023-03-27 20:58:20.396 24711-24711 Ads                     com.my.package         I  Use RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("333C8AE82F2C89B0AF4DCBD658E0F35C")) to get test ads on this device.
2023-03-27 20:58:20.401 24711-24763 FA                      com.my.package         V  Activity paused, time: 2548080784
2023-03-27 20:58:20.401 24711-24763 FA                      com.my.package         V  Activity resumed, time: 2548080807
2023-03-27 20:58:20.406 24711-25006 AudioManager            com.my.package         I  In isSpeakerphoneOn(), calling application: # Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
2023-03-27 20:58:20.419 24711-24711 DecorView[]             com.my.package         D  onWindowFocusChanged hasWindowFocus false
2023-03-27 20:58:20.435 24711-25183 Ads                     com.my.package         W  Not retrying to fetch app settings
2023-03-27 20:58:20.460  3263-3714  ActivityManagerWrapper  com.miui.home                        E  getRecentTasks: taskId=5899   userId=0   baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=# Enables namespacing of each library's R class so that its R class includes only the
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library/.activities.ActivitySplash }
2023-03-27 20:58:20.521 24711-24711 DecorView[]             com.my.package         D  onWindowFocusChanged hasWindowFocus true
2023-03-27 20:58:20.538 24711-24711 RecyclerView            com.my.package         W  No adapter attached; skipping layout
2023-03-27 20:58:21.265 24711-25240 BufferPoolAccessor2.0   com.my.package         D  bufferpool2 0xb40000789c40d628 : 5(40960 size) total buffers - 0(0 size) used buffers - 21/27 (recycle/alloc) - 10/27 (fetch/transfer)
2023-03-27 20:58:21.265 24711-25240 BufferPoolAccessor2.0   com.my.package         D  bufferpool2 0xb4000079959dc428 : 5(40960 size) total buffers - 0(0 size) used buffers - 15/20 (recycle/alloc) - 7/20 (fetch/transfer)
2023-03-27 20:58:21.265 24711-25240 BufferPoolAccessor2.0   com.my.package         D  evictor expired: 2, evicted: 2
2023-03-27 20:58:21.909 24711-24711 Ads                     com.my.package         W  GET LOCATION COMPILED
2023-03-27 20:58:21.980 24711-24711 ExoPlayerImpl           com.my.package         I  Init 43758ef [AndroidXMedia3/1.0.0-beta03] [curtana, Redmi Note 9 Pro, Xiaomi, 31]
2023-03-27 20:58:21.991 24711-24711 Ads                     com.my.package         I  ExoPlayerAdapter initialized.
2023-03-27 20:58:22.287 24711-25340 DMCodecAdapterFactory   com.my.package         I  Creating an asynchronous MediaCodec adapter for track type audio
2023-03-27 20:58:22.289 24711-25349 CCodec                  com.my.package         D  allocate(c2.android.aac.decoder)
2023-03-27 20:58:22.293 24711-25349 CCodec                  com.my.package         I  Created component [c2.android.aac.decoder]

已尝试的排查操作

  • 打开其他Activity,问题复现
  • 卸载重装应用,问题依旧
  • 模拟器与真机测试,结果一致
  • 移除目标Activity中的Admob广告,问题仍存在

补充信息

即使ActivitySplash已执行finish(),Logcat仍会出现红色报错行:

getRecentTasks: taskId=5942   userId=0   baseIntent=Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.my.package/.activities.ActivitySplash }

相关配置代码(AndroidManifest、Build.gradle、Application、ActivitySplash)已附上,恳请协助排查解决该问题。


内容的提问来源于stack exchange,提问作者Dhiraj Thapaliya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 21:47:16