适用于 Google APIS(云端硬盘和表格)的新华为设备(无 Google Play 服务)中 Google 登录的替代方案

Day*_*iel 5 android google-drive-api google-play-services google-sheets-api huawei-mobile-services

我非常担心,因为华为个人联系了我,他们解释说新手机不会安装 Play 服务(旧消息)。我工作中的应用程序目前使用不同的 Google 服务:play-services-ads、play-services-auth、firebase-messaging、firebase-analytics、Crashlytics、Google Sheets、Google Drive。

我们使用 Google Sign-in 来获取 GoogleAccountCredential 以调用 Drive/Sheets API:

                GoogleAccountCredential credential = GoogleAccountCredential
                        .usingOAuth2(HomeActivity.this,
                                //Collections.singleton(DriveScopes.DRIVE_FILE));
                                Collections.singleton(DriveScopes.DRIVE));

public static DriveServiceHelper initDriveService(GoogleAccountCredential mCredential) {
    if(mDriveService == null && mCredential != null){
        // servicio drive
        mDriveService = new Drive.Builder(
                AndroidHttp.newCompatibleTransport(),
                new GsonFactory(),
                mCredential)
                .setApplicationName(getString(R.string.app_name))
                .build();
    }
    if(mSheetsService == null && mCredential != null){
        // servicio sheets
        mSheetsService = new Sheets.Builder(
                AndroidHttp.newCompatibleTransport(),
                new GsonFactory(),
                mCredential)
                .setApplicationName(getString(R.string.app_name))
                .build();
    }
    //driveServiceHelper = new DriveServiceHelper(googleDriveService);
    return new DriveServiceHelper(mDriveService, mSheetsService, mCredential);
}
Run Code Online (Sandbox Code Playgroud)

可以使用前面提到的新华为设备中安装的 APIS(没有 Google Play 服务)并获取必要的凭据的替代方案是什么?

zha*_*hen 0

1\xef\xbc\x8e 您的应用程序已集成 GMS。由于新的华为手机被禁止使用GMS,您的应用程序如果集成了GMS,将无法在新的华为手机上运行。如果您希望您的应用在这些手机上运行,​​请集成华为移动服务(HMS)。\n如果您想在您的应用中使用驱动服务,并且希望您的应用同时在华为手机和 Google Android 手机上运行,​​您可以集成Google Drive和HMS Drive套件。那么你的应用程序在华为手机上将使用HMS Drive Kit,而在谷歌Android手机上将使用Google Drive。

\n

在您提供的列表中,您使用以下 GMS 服务:

\n
    \n
  • 播放服务广告
  • \n
  • 播放服务验证
  • \n
  • firebase 消息传递
  • \n
  • firebase-分析
  • \n
  • 崩溃解决方案
  • \n
  • 谷歌云端硬盘
  • \n
\n

您可以参考以下华为移动服务:

\n\n
    \n
  1. 您可以使用HMS Core Toolkit这个IDE插件来帮助您分析代码中哪些地方使用了GMS。HMS Core Toolkit实现应用的创建、编码、转换、调试、测试和发布。
  2. \n
\n
    \n
  • Converter是一个支持 Java 和 Kotlin 项目的代码转换工具。该工具可以帮助您快速将现有的调用第三方API的Android应用代码转换为集成HMS Core的应用代码。
  • \n
  • HMS Core Toolkit暂不支持自动下载AppGallery Connect配置文件,后续版本将规划。
  • \n
\n