谷歌aab包在Android 14闪退而apk没问题(targetsdk 34)

这篇具有很好参考价值的文章主要介绍了谷歌aab包在Android 14闪退而apk没问题(targetsdk 34)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题原因

Unity应用(target SDK 34)上线到GooglePlay,有用户反馈fold5设备上(Android14系统)疯狂闪退,经测试,在小米手机Android14系统的版本复现成功了,奇怪的是apk直接安装没问题,而打包成aab就是疯狂闪退。

Unity版本Unity2020.3.18f1c1。

老办法,logcat抓包,看看闪退日志。

日志有一行引起了我的注意,也就是在闪退前的报错:

No pending exception expected: java.lang.SecurityException: com.xxx.xxx: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

既然有错误,就好解决了,现在问ChatGPT没用的,因为ChatGPT经常会瞎编,所以上谷歌搜索下,立马就搜到了。 android - One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts - Stack Overflowjava.lang.securityexception:one of receiver_exported or receiver_not_exporte,游戏开发踩坑记录,Android,android,unity,游戏引擎

 As discussed at Google I/O 2023, registering receivers with intention using the RECEIVER_EXPORTED / RECEIVER_NOT_EXPORTED flag was introduced as part of Android 13 and is now a requirement for apps running on Android 14 or higher (U+).

If you do not implement this, the system will throw a security exception.

To allow the broadcast receiver to receive broadcasts from other apps, register the receiver using the following code:

context.registerReceiver(broadcastReceiver, intentFilter, RECEIVER_EXPORTED);

To register a broadcast receiver that does not receive broadcasts from other apps, including system apps, register the receiver using the following code:

context.registerReceiver(broadcastReceiver, intentFilter, RECEIVER_NOT_EXPORTED);

Note: That call will need minSdkVersion to be 26 (Android 8) al least

Check https://www.delasign.com/blog/android-studio-kotlin-broadcast-recievers-export-or-not/#:~:text=As%20discussed%20at%20Google%20I,will%20throw%20a%20security%20exception.

翻译过来就是,Goole I/O 2023讨论的,使用RECEIVER_EXPORTED / RECEIVER_NOT_EXPORTED标志注册接收者是Android 13的一部分,现在是运行在Android 14或更高版本(U+)上的应用程序的要求。也就是Android14必须增加该标志。

以前使用registerReceiver不需要设置RECEIVER_EXPORTED / RECEIVER_NOT_EXPORTED这个Flag,现在Android14开始需要设置了,所以抛异常,闪退了。

解决思路

问题找到了,也分析好了,但是因为这是Unity工程直接打包出来的aab,像是一个黑箱,而问题就是Unity打包出来写的registerReceiver没有按照Android14的要求传进去Flag,这个我们可以通过日志确定,可以看到堆栈日志显示com.unity3d.player.PlayAssetDeliveryUnityWrapper.registerDownloadStatusListener这个类注册的Receiver,而这个是Unity的类,无法修改。

2024-01-12 17:45:50.379 6394-6494/? A/ongame.isoland4: thread.cc:2529] No pending exception expected: java.lang.SecurityException: com.cottongame.isoland4: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
    thread.cc:2529]   at java.lang.Exception android.os.Parcel.createExceptionOrNull(int, java.lang.String) (Parcel.java:3057)
    thread.cc:2529]   at java.lang.Exception android.os.Parcel.createException(int, java.lang.String) (Parcel.java:3041)
    thread.cc:2529]   at void android.os.Parcel.readException(int, java.lang.String) (Parcel.java:3024)
    thread.cc:2529]   at void android.os.Parcel.readException() (Parcel.java:2966)
    thread.cc:2529]   at android.content.Intent android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(android.app.IApplicationThread, java.lang.String, java.lang.String, java.lang.String, android.content.IIntentReceiver, android.content.IntentFilter, java.lang.String, int, int) (IActivityManager.java:6193)
    thread.cc:2529]   at android.content.Intent android.app.ContextImpl.registerReceiverInternal(android.content.BroadcastReceiver, int, android.content.IntentFilter, java.lang.String, android.os.Handler, android.content.Context, int) (ContextImpl.java:1863)
    thread.cc:2529]   at android.content.Intent android.app.ContextImpl.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter, java.lang.String, android.os.Handler) (ContextImpl.java:1803)
    thread.cc:2529]   at android.content.Intent android.app.ContextImpl.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter) (ContextImpl.java:1791)
    thread.cc:2529]   at android.content.Intent android.content.ContextWrapper.registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter) (ContextWrapper.java:766)
    thread.cc:2529]   at void com.google.android.play.core.listener.b.b() ((null):-1)
    thread.cc:2529]   at void com.google.android.play.core.listener.b.f(com.google.android.play.core.listener.StateUpdatedListener) ((null):-1)
    thread.cc:2529]   at void com.google.android.play.core.assetpacks.i.registerListener(com.google.android.play.core.assetpacks.AssetPackStateUpdateListener) ((null):-1)
    thread.cc:2529]   at java.lang.Object com.unity3d.player.a.a(com.unity3d.player.IAssetPackManagerDownloadStatusCallback) ((null):-1)
    thread.cc:2529]   at java.lang.Object com.unity3d.player.PlayAssetDeliveryUnityWrapper.registerDownloadStatusListener(com.unity3d.player.IAssetPackManagerDownloadStatusCallback) ((null):-1)
    thread.cc:2529]   at boolean com.unity3d.player.UnityPlayer.nativeRender() ((null):-2)
    thread.cc:2529]   at boolean com.unity3d.player.UnityPlayer.access$300(com.unity3d.player.UnityPlayer) ((null):-1)
    thread.cc:2529]   at boolean com.unity3d.player.UnityPlayer$e$1.handleMessage(android.os.Message) ((null):-1)
    thread.cc:2529]   at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
    thread.cc:2529]   at boolean android.os.Looper.loopOnce(android.os.Looper, long, int) (Looper.java:224)
    thread.cc:2529]   at void android.os.Looper.loop() (Looper.java:318)
    thread.cc:2529]   at void com.unity3d.player.UnityPlayer$e.run() ((null):-1)
    thread.cc:2529] 

解决

目前解决方案是targetsdk改成33,经测试就不闪退了。

如果你需要targetsdk为34,得升级下Unity版本,看看哪个版本修复了这个问题。我们的版本是Unity2020.3.18f1c1。查了3.19的Release Note没有找到相关的修复,懒得找了。文章来源地址https://www.toymoban.com/news/detail-831780.html

到了这里,关于谷歌aab包在Android 14闪退而apk没问题(targetsdk 34)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 谷歌aab包手机怎么安装教程

    二、下载与配置 bundletool Github 下载地址:https://github.com/google/bundletool 准备环境 使用bundletool工具需要java环境,建议使用JRE8环境,请自行下载安装,并配置好系统环境变量 下载bundletool.jar包 使用cmd命令将aab文件转换为apks文件 命令格式参考如下: 使用cmd命令安装apks文件到手

    2024年02月05日
    浏览(30)
  • Unity项目发布谷歌AAB+PAD

    一切的根源都在谷歌商店。 谷歌商店一直对上架的应用和游戏有严格的要求。最早期的时候,谷歌商店要求apk容量限制在50mb内,后来随着应用的普遍容量增大,谷歌商店把apk的容量限制放宽到100mb。 但对于游戏来说,100mb的容量明显不够用。于是谷歌在早期提出了apk+obb(Opa

    2023年04月24日
    浏览(41)
  • Selenium安装WebDriver:最新ChromeDriver谷歌驱动及闪退等常见问题(114及其以后的版本)

    点击进去可以看到下载链接   截止2023.9.12我的谷歌浏览器版本是 116.0.5845.188(正式版本) 我选择了  116.0.5845.96  ( r1160321 )(最后一个) 随着版本更新,大家要根据自己浏览器版本进行选择相应驱动,尽量保证驱动版本和浏览器版本一致,前三位保持一致一般就可以正常使

    2024年02月22日
    浏览(53)
  • 使用Xcode 14.3 打包,在iOS13 系统上闪退问题

    Date/Time:           2023-04-21 16:49:28.3937 +0800 Launch Time:         2023-04-21 16:49:27.7110 +0800 OS Version:          iPhone OS 13.4.1 (17E262) Release Type:        User Baseband Version:    1.05.28 Report Version:      104 Exception Type:  EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception No

    2024年02月06日
    浏览(55)
  • Python+selenium自动化测试——启动谷歌浏览器闪退问题 Traceback (most recent call last)

    后台报错:Traceback (most recent call last) 当我们使用Python+selenium调用谷歌浏览器出现闪退问题时,其实是谷歌的驱动和浏览器的版本不一致。 from time import sleep from selenium import webdriver driver=webdriver.Chrome()  1.下载谷歌浏览器驱动=浏览器版本——对应上 http://chromedriver.storage.googlea

    2024年02月11日
    浏览(37)
  • 【Android】SDK Manager打开闪退问题

    1、找到android.bat文件,在android-sdk-windowstools目录下 2、右击android.bat文件,选择编辑。 找到如下位置: rem Check we have a valid Java.exe in the path. set java_exe= call libfind_java.bat if not defined java_exe goto :EOF 3、更改路径为java的绝对路径 rem Check we have a valid Java.exe in the path. set java_exe=“ja

    2024年02月14日
    浏览(36)
  • Android逆向进阶,APK签名问题

    APK签名的原理基于公钥加密和数字证书的机制。在APK签名过程中,开发者使用私钥对应用的数字摘要进行加密,生成签名文件。然后,开发者将应用和签名文件一同发布。当用户下载应用时,系统会使用开发者的公钥对签名文件进行解密,并与应用的数字摘要进行比对,以验

    2024年02月11日
    浏览(39)
  • Android studio:打开应用程序闪退的问题

    在开发Android应用程序的过程中遇到的问题 在开发(或者叫测试,这么简单的程序可能很难叫开发)好一个android之后,在Android studio中调试开发好的app时,编辑器没有提示错误,在虚拟机中的下载也没有问题,但是app一打开就闪退,再次打开就会出现app keeps stopping的字样 查看

    2024年02月04日
    浏览(41)
  • 解决android studio中页面闪退的几个问题

    1.如果在新建页面时闪退,解决方法如下 先去miantext里面检查是否注册了当前页面,如果没有注册,需在maintext里面机型注册 如下图(一般来说,AS在新建activity时会自动注册) 如下图 或者alt+enter-Add activity to manifest 可解决问题 2.点击按钮时闪退  如果我的按钮想实现点击跳转

    2024年02月11日
    浏览(30)
  • Android Studio 无法安装apk到小米手机问题解决

    以前开发都是用自己的samsung手机,打开开发者选项和usb调试,直接可以连上Android Studio,进行调试,后来我的samsung退伍了,换上了Apple,就无法使用了,用公司的小米手机打开开发者选项和usb调试,然后进行调试,将apk安装小米手机安装应用报错(Failed to establish session Erro

    2024年02月15日
    浏览(58)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包