0

尝试使用 dexguard 在发布模式下打开 HMS 地图时遇到此问题。应用程序崩溃并给出此异常:

libc:致命信号 11 (SIGSEGV),代码 1 (SEGV_MAPERR),tid 19062 (GLThread 249) 中的故障地址 0x0,pid 15351 (nza.ambitwizhmb) 2022-01-25 23:44:02.463 19184-19184/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** * ** 2022-01-25 23:44:02.463 19184-19184/? A/DEBUG:构建指纹:'HUAWEI/JNY-LX1/HWJNY:10/HUAWEIJNY-L21/10.1.0.386C185:user/release-keys' 2022-01-25 23:44:02.463 19184-19184/? A/DEBUG: uid: 10196 2022-01-25 23:44:02.463 19184-19184/? A/DEBUG:信号 11 (SIGSEGV),代码 1 (SEGV_MAPERR),故障地址 0x0

当我在调试模式下运行该应用程序时,它运行得非常好。打开地图时,崩溃时间会有所不同。有时地图显示正确,但有时在加载时会崩溃。

hms 的 dexguard 配置是

-keep class com.huawei.agconnect.**{*;}
-dontwarn com.huawei.agconnect.**
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep interface com.huawei.hms.analytics.type.HAEventType{*;}
-keep interface com.huawei.hms.analytics.type.HAParamType{*;}
-keep class com.huawei.agconnect.** {*;}
-keepresources string/agc_*
-keepresources string/upsdk_store_url
-keepresources string/hms_update_title
-keepresourcefiles assets/hmsrootcas.bks
-keepresourcefiles assets/grs_*
4

1 回答 1

0

建议您参考此文档配置混淆。

  1. 打开proguard-rules.pro项目应用根目录下的混淆配置文件,添加配置排除HMS Core SDK混淆。
-ignorewarnings 
-keepattributes *Annotation* 
-keepattributes Exceptions 
-keepattributes InnerClasses 
-keepattributes Signature 
-keepattributes SourceFile,LineNumberTable 
-keep class com.huawei.hianalytics.**{*;} 
-keep class com.huawei.updatesdk.**{*;} 
-keep class com.huawei.hms.**{*;}
  1. 如果您使用的是 AndResGuard,请将其信任列表添加到build.gradle项目的应用程序级文件中。
"R.string.agc*",
"R.string.hms*", 
"R.string.connect_server_fail_prompt_toast", 
"R.string.getting_message_fail_prompt_toast", 
"R.string.no_available_network_prompt_toast", 
"R.string.third_app_*", 
"R.string.upsdk_*", 
"R.layout.hms*", 
"R.layout.upsdk_*", 
"R.drawable.upsdk*", 
"R.color.upsdk*", 
"R.dimen.upsdk*", 
"R.style.upsdk*"
  1. (可选)如果您启用了 R8 资源收缩(在项目级文件中设置为)和严格引用检查(在文件中设置为) keep.xml,请按如下配置文件以保留布局资源。不保留布局资源会导致应用在发布到华为应用市场时被拒绝。shrinkResourcestruebuild.gradleshrinkModestrictres/raw/keep.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
    tools:keep="@layout/hms_download_progress,@drawable/screen_off,@layout/upsdk*"
    tools:shrinkMode="strict" />
于 2022-01-26T01:26:10.090 回答