将 app/build.gradle 的 targetSdkVersion 改为 34.
然后在Android Studio点击运行到手机
手机上App启动后闪退
- 发布:2024-09-30 15:13
- 更新:2024-10-21 11:40
- 阅读:269
产品分类: uniapp/App
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: macOS 14.4.1
HBuilderX类型: 正式
HBuilderX版本号: 3.8.7
手机系统: Android
手机系统版本号: Android 14
手机厂商: 小米
手机机型: 小米12
页面类型: vue
vue版本: vue2
打包方式: 离线
项目创建方式: HBuilderX
操作步骤:
预期结果:
App正常打开
App正常打开
实际结果:
App在闪屏页面就闪退了, 报出SecurityException的异常
App在闪屏页面就闪退了, 报出SecurityException的异常
bug描述:
本App的targetSdkVersion 为30时在各种Android设备上都是正常的运行, 但是提交到Google Play商店, 需要将targetSdkVersion改为34, 打包后, 在Android 14 (SDK 34) 启动页面闪退.
Google developer上 Android 14的升级说明:
https://developer.android.com/about/versions/14/behavior-changes-14?hl=zh-cn#runtime-receivers-exported
在运行时注册的广播接收器必须指定导出行为
以 Android 14(API 级别 34)或更高版本为目标平台并使用上下文注册的接收器的应用和服务必须指定一个标志,以指明接收器是否应导出到设备上的所有其他应用:分别为 RECEIVER_EXPORTED 或 RECEIVER_NOT_EXPORTED。此要求有助于利用 Android 13 中引入的这些接收器的功能,保护应用免受安全漏洞的影响。
报错信息:
2024-09-30 14:27:37.321 1052-1052/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ola100.app2, PID: 1052
java.lang.SecurityException: com.ola100.app2: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
at android.os.Parcel.createException(Parcel.java:3041)
at android.os.Parcel.readException(Parcel.java:3024)
at android.os.Parcel.readException(Parcel.java:2966)
at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:6193)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1863)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1803)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:778)
at io.dcloud.WebAppActivity.i(Unknown Source:36)
at io.dcloud.WebAppActivity.onRuntimeCreate(Unknown Source:1)
at io.dcloud.b$a$a.run(Unknown Source:1)
at io.dcloud.b$c.onCallBack(Unknown Source:9)
at io.dcloud.b.a(Unknown Source:175)
at io.dcloud.b.a(Unknown Source:2)
at io.dcloud.b$a.run(Unknown Source:10)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:224)
at android.os.Looper.loop(Looper.java:318)
at android.app.ActivityThread.main(ActivityThread.java:8754)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:561)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:14680)
at android.app.IActivityManager$Stub.onTransact$registerReceiverWithFeature$(IActivityManager.java:12174)
at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3173)
at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2856)
at android.os.Binder.execTransactInternal(Binder.java:1346)
2024-09-30 14:27:40.331 1052-1052/? W/System.err: at io.dcloud.WebAppActivity.i(Unknown Source:36)
2024-09-30 14:27:40.331 1052-1052/? W/System.err: at io.dcloud.WebAppActivity.onRuntimeCreate(Unknown Source:1)
4 个回复
DCloud_Android_zl
升级到最新版HBuilderX重新打包试下
wwwzzz
楼主解决了吗
c***@youyoukj.com (作者)
还没有, 最近几天没处理
1***@qq.com
遇到一样的问题,有解决方案吗?