Huawei AGConnectAuth Phone number authentication error: ONLY ONE String Field can be annotated as Url

Huawei AGConnectAuth Phone number authentication error: ONLY ONE String Field can be annotated as Url

我想在我的应用程序中使用 phone 身份验证。 当我 运行 android studio 中的应用程序时,该功能运行良好。

但是当我从应用程序库安装已发布的应用程序时,我遇到了这个错误:“ONLY ONE String Field can be annotated as Url

这是build.gradle文件:

...
signingConfigs {
   config {
      storeFile file('/Users/username/AndroidStudioProjects/somepath/example.jks')
      storePassword 'password'
      keyAlias 'foldername'
      keyPassword 'password'
   }
}

...
buildTypes {
  debug {
    minifyEnabled false
    debuggable true
    signingConfig signingConfigs.config
  }

  release {
    signingConfig signingConfigs.config
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  }
}

这是phone认证请求码:

private void startPhoneNumberVerification() {
        // [START start_phone_auth]
        VerifyCodeSettings settings = new VerifyCodeSettings.Builder()
                .action(VerifyCodeSettings.ACTION_REGISTER_LOGIN)
                .locale(Locale.getDefault())
                .sendInterval(30)
                .build();
        Task<VerifyCodeResult> task = AGConnectAuth.getInstance().requestVerifyCode(countryCode, phoneNumberWithoutCountryCode, settings);
        task.addOnSuccessListener(TaskExecutors.uiThread(), new OnSuccessListener<VerifyCodeResult>() {
            @Override
            public void onSuccess(VerifyCodeResult verifyCodeResult) {
                phoneNumberContainer.setVisibility(View.GONE);
                verifyCodeContainer.setVisibility(View.VISIBLE);
            }
        }).addOnFailureListener(TaskExecutors.uiThread(), new OnFailureListener() {
            @Override
            public void onFailure(Exception e) {
                Log.e(TAG, "CODE SEND ERROR : " + e.getMessage());
                // Error : code: 2 message: ONLY ONE String Field can be annotated as Url
                
                }
            }
        });
        // [END start_phone_auth]
    }

应用签名设置

项目设置

谢谢大家的建议。

尝试添加以下混淆脚本可能会解决您的问题。

-keep class com.huawei.agconnect.** {*;}
-keepresourcexmlelements **
-keepresources */*

在 ProGuard 规则中,添加:

-keep class com.huawei.agconnect.** {*;}

这对我有用。