android - 用于 Google APIS(驱动器和表格)的新华为设备(无 Google Play 服务)中 Google 登录的替代方案

标签 android google-drive-api google-play-services google-sheets-api huawei-mobile-services

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

我们使用 Google 登录来获取 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);
}

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

最佳答案

1.您的应用已集成 GMS。由于新的华为手机被禁止使用 GMS,如果您的应用程序集成了 GMS,将无法在新的华为手机上运行。如果您希望您的应用在这些手机上运行,​​请集成华为移动服务 (HMS)。
如果你想在你的应用中使用驱动服务,并且希望你的应用同时运行在华为手机和谷歌安卓手机上,你可以集成谷歌驱动和HMS驱动套件。然后您的应用将在华为手机上使用 HMS Drive Kit,而在 Google Android 手机上使用 Google Drive。
在您提供的列表中,您使用以下 GMS 服务:

  • 播放服务广告
  • 播放服务身份验证
  • firebase 消息
  • firebase 分析
  • 崩溃分析
  • 谷歌云端硬盘

  • 您可以引用以下华为移动服务:
  • Ads Kit
  • Account Kit , AppGallery Connect Auth Service
  • Push Kit
  • Analytics Kit
  • AppGallery Connect Crash Service
  • Drive Kit
  • 您可以使用这个名为 HMS Core Toolkit 的 IDE 插件。帮助您分析代码中使用 GMS 的位置。 HMS Core Toolkit 实现了应用的创建、编码、转换、调试、测试和发布。
  • The Convertor是一个支持 Java 和 Kotlin 项目的代码转换工具。该工具可以帮助您将现有的调用第三方API的Android应用代码快速转换为与HMS Core集成的应用代码。
  • HMS Core Toolkit不支持自动下载AppGallery Connect配置文件,后续版本会规划。
  • 关于android - 用于 Google APIS(驱动器和表格)的新华为设备(无 Google Play 服务)中 Google 登录的替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60177372/

    相关文章:

    android - com.google.android.gms.common.api.ApiException : 10

    android - float 操作按钮不显示在 recyclerview 上(位于 DrawerLayout 内)

    android - 如何分享已安装的应用程序?

    android - url 加载后将 webview 滚动到顶部

    google-sheets - bigQuery Google Drive Sheets 在一张表中显示多个工作表

    python - Google Drive API 的刷新 token 何时到期?

    Android:如果从通知栏恢复应用程序,则绘制的 Canvas 油漆消失了

    python - 适用于 python 的 Google Api 客户端库不会在文件 : list method with query 中返回 nextPageToken

    android - 我应该始终使用最新版本的 Google Play 服务吗?

    Android - Google+ 分享状态失败