【问题标题】:Google AppInvite谷歌应用邀请
【发布时间】:2016-03-25 18:53:47
【问题描述】:

通过Google 手动实现Google AppInvite - link

开始邀请 Activity 并在 LogCat 中获取下一个:

E/AppInviteAgent: Get suggested invitees failed due to error code: 3
            No Android client ID is found for package name <MY_PACKAGE_NAME>. (APPINVITE_CLIENT_ID_ERROR)

E/AppInviteAgent: Create invitations failed due to error code: 3
            No Android client ID is found for package name <MY_PACKAGE_NAME>. (APPINVITE_CLIENT_ID_ERROR)

然后我在 onActivityResult 方法中添加一个 Log.d 并进入 LogCat:

onActivityResult: requestCode=0, resultCode=3

有人可以帮助我吗?我尝试在 2 周左右修复它。

UPD0

// my `build.gradle` file (project level)
  dependencies {
    classpath 'com.android.tools.build:gradle:2.0.0-beta6'
    classpath 'com.google.gms:google-services:2.0.0-beta6'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  }
// my `build.gradle` file (app level)

compileSdkVersion 23
buildToolsVersion '23.0.2'
// ... some code
dependencies {
     compile fileTree(include: ['*.jar'], dir: 'libs')
     testCompile 'junit:junit:4.12'
     compile 'com.android.support:appcompat-v7:23.2.0'
     compile 'com.android.support:design:23.2.0'
     compile 'com.google.android.gms:play-services-ads:8.4.0'
     compile 'com.google.android.gms:play-services-appinvite:8.4.0'
     // for in-app-billing v3
     compile 'com.anjlab.android.iab.v3:library:1.0.31'
}
// and in the end of the file
// for Google Invite
apply plugin: 'com.google.gms.google-services'

// my methods in the MainActivity
private void onInviteClicked() {
        Intent intent = new AppInviteInvitation.IntentBuilder(
                getString(R.string.txt_invitation_title))
                .setMessage(getString(R.string.txt_invitation_message))
                .setCallToActionText(getString(R.string.txt_invitation_cta))
                .build();
        startActivityForResult(intent, REQUEST_INVITE);
}
// where REQUEST_INVITE - private static final int and equal 0;

// and onActivityResult - copy from `Google` manual
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    new MyLogs("onActivityResult: requestCode=" + requestCode + ", resultCode=" + resultCode);

    if (requestCode == REQUEST_INVITE) {
        if (resultCode == RESULT_OK) {
            // Check how many invitations were sent and log a message
            // The ids array contains the unique invitation ids for each invitation sent
            // (one for each contact select by the user). You can use these for analytics
            // as the ID will be consistent on the sending and receiving devices.
            String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data);
            new MyLogs(getString(R.string.sent_invitations_fmt, ids.length));
        } else {
            // Sending failed or it was canceled, show failure message to the user
            new MyLogs("send_failed");
        }
    }
}

【问题讨论】:

  • 您能否提供更多信息,例如你想达到什么,一些源代码等。
  • @manniL,检查 update0。

标签: java android google-app-invites


【解决方案1】:

你是否包含了 json 配置文件?

【讨论】:

    【解决方案2】:

    在项目设置下的 firebase 控制台中,找到“证书指纹 (SHA-1)”部分,然后从帮助图标中,您将被定向到 https://developers.google.com/android/guides/client-auth 并输入生成的 SHA1 密钥以用于发布和调试证书指纹。然后 resultCode 3 将消失,您将发送邀请。

    【讨论】:

      【解决方案3】:

      您可能需要在发布模式而不是调试模式下生成 APK。

      【讨论】:

      • 我在 Google Play 中有一个应用程序,但 appinvite 在那里不起作用。
      【解决方案4】:

      您是否在Google Developers Console 中仔细检查了您项目的OAuth 客户端ID

      确保正确放置项目的 SHA-1包名称。我建议您创建 两个 客户端 ID:一个使用 SHA-1 用于 debug 密钥,另一个用于 release 密钥。

      您还可以安全地删除应用级 build.gradle 文件中的 google-services.json 文件和 apply plugin: 'com.google.gms.google-services' 代码,因为 “它只是生成一些基本的 android-resource 文件以便更轻松地集成特定Google API 功能。”here 所述。

      【讨论】:

      • 是的,我的 Google Developer Console 中有一个 OAuth 客户端 ID。好吧,如果我要删除 *.json 文件和“应用插件:...”,当我在带有签名的真实设备上启动我的应用程序时,我的应用程序邀请将开始?我不想为测试应用程序邀请发布新版本.
      • 报错... No Android client ID is found for package name ...,您确定您在项目的OAuth Client ID中输入了正确 包名吗?是的,它可以正常工作,我已经在我的 J5 调试版本和 Google Play 开发者控制台上的 Alpha APK 上对其进行了测试。
      • 您还确定这是您的OAuth Client ID不是 API Keyhere 所述吗?
      • 是的,因为名称是“ 的 Android 客户端(由 Google 服务自动创建)”
      • 简单,我删除了 OAuth 并创建了新的。但这对我没有帮助。
      【解决方案5】:

      如果您已将 Firebase 与 Google Play 上的应用连接,我认为它应该会自动运行,但您必须从 Google Play 下载您的应用。我遇到了同样的问题,但在我的情况下它不起作用,因为我有直接从计算机安装的应用程序版本(调试模式)。

      【讨论】:

        猜你喜欢
        • 2015-12-19
        • 1970-01-01
        • 2015-08-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多