HMS Dexguard Obfuscation issue

530 Views Asked by At

I have implemented dexguard in my application. Application is working when no obfuscation is done but crashes as dexguard obfuscation is done.

it gives the error.

Caused by: android.view.InflateException: Binary XML file line #0 in com.avanza.ambitwizhmb:layout/2131558492: Error inflating class fragment

Caused by: com.huawei.hms.maps.model.RuntimeRemoteException: AppId is null. Please check whether the agconnect-services.json file is added to your app project.

the dexguard rules for huawei is:

-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{*;}
2

There are 2 best solutions below

0
zhangxaochen On

If Dexguard obfuscation is used during app packaging, you need to configure the following:

-ignorewarnings
-keep class com.huawei.agconnect.** {*;}
-keepresourcexmlelements **
-keepresources /
0
lj279 On
After obfuscation hms map not able to get appid from agconnect json, best way to fix this issue, add the appid in android manifest also like this 
" <meta-data
            android:name="com.huawei.hms.client.appid"
            android:value="appid=xxxxxx" />"