android-studio - HMS 工具包转换(G+H、HMS API 1st)库(xmsadapter)无法导入

标签 android-studio firebase-authentication huawei-mobile-services huawei-developers

我正在尝试使用 HMS Toolkit 将我的应用程序从 GMS 移植到 (G+H)。
使用 Toolkit Converter 后,以下行会抛出 Unresolved reference 错误 import org.xms.f.auth.ExtensionAuth要求定义 xms。这显然意味着 xmsadapter 文件(由 HMS Toolkit Convertor 生成)尚未导入。
如何修复此错误以在 import org.xms.f.auth.ExtensionAuth 上导入 .xms 文件我觉得我缺少一种依赖?
enter image description here

最佳答案

您还可以先检查配置的混淆脚本。
使用 Add HMS API 策略生成的 XMS 代码会增加您的应用程序的大小。您可以通过在中添加或修改以下配置来开启代码缩减功能。 app/build.gradle 文件:

android {
     buildTypes {
         release {
             minifyEnabled true
             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
         }
     }
}
如果出现 等错误信息“找不到...” , “NoClassDefFoundError” , “ClassNotFoundException” , “NoSuchFieldException” , 或 “NoSuchMethodException” minifyEnabled设置为true后显示,在中配置如下XMS混淆规则app/proguard-rules.pro :
-ignorewarnings
-keepattributes *Annotation*
-keepattributes Exceptions
-keepattributes InnerClasses
-keepattributes Signature
-keepattributes SourceFile,LineNumberTable
-keep class com.hianalytics.android.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.hms.**{*;}
-keep class com.huawei.agconnect.**{*;}
-keep interface com.huawei.agconnect.**{*;}
-keep class com.huawei.hmf.**{*;}

-keep class com.google.android.gms.**{*;}
-keep interface com.google.android.gms.**{*;}

-keep class com.google.firebase.**{*;}
-keep interface com.google.firebase.**{*;}

-keep class org.xms.**{*;}
-keep interface org.xms.**{*;}
详情可以引用这个Docs .

关于android-studio - HMS 工具包转换(G+H、HMS API 1st)库(xmsadapter)无法导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68050433/

相关文章:

huawei-mobile-services - json int数据类型自动变为double

android - 异常(exception):重复条目:android/support/v7/widget/CardViewApi21.class

android - 如何在 Android Studio 2.2 中手动选择目标设备?

huawei-mobile-services - HMS Push插件-应用处于kill状态时如何接收数据消息

swift - 如何分别从 Firebase Auth 和实时数据库中自动删除用户和用户的数据?

node.js - Firebase Admin SDK - 使用自定义字段创建用户

android - HMS Core APK 在 x86 上安装和运行

android - 安装apk文件时出现错误 "The package appears to be corrupt"

android-studio - Android Studio 在创建新的 Flutter 项目时卡住了

android - 是否可以通过 firebase auth 仅使用短信服务和离线注册用户,即没有互联网