3

Realize Google AppInvite by Google manual - link.

Start Invite Activity and get next in the 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)

Then I add a Log.d in the onActivityResult method and get in the LogCat:

onActivityResult: requestCode=0, resultCode=3

Can somebody help me ? I try to fix it about 2 weeks.

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");
        }
    }
}
Oleksandr.D
  • 200
  • 7
  • 15

5 Answers5

1

Did you include the json configuration file?

Sergio Viudes
  • 2,714
  • 5
  • 26
  • 44
1

In firebase console under Project Settings find "Certificate Fingerprints (SHA-1)" part and from the help icon you will be directed to https://developers.google.com/android/guides/client-auth and enter generated SHA1 keys for both release and debug certificate fingerprints. Then resultCode 3 will gone and you will send the invitation.

Baris
  • 797
  • 2
  • 10
  • 15
0

You may need to generate your APK in release mode, not debug mode.

Dongfu He
  • 41
  • 5
0

Have you double-checked your OAuth Client ID of your project in Google Developers Console?

Make sure you correctly put your project's SHA-1 and package name. I suggests you created two client IDs: one with SHA-1 for debug key, and another for release key.

You can also safely remove google-services.json file and apply plugin: 'com.google.gms.google-services' code in your app-level build.gradle file since "it is just a quickstart helper to generate some basic android-resource files for easier integration of specific Google API features." as described here.

Community
  • 1
  • 1
simplebe
  • 228
  • 3
  • 14
  • Yes, I have an OAuth Client ID in my Google Developer Console. Okey, if I will delete a `*.json` file and `apply plugin: ..." my app invite will be started when I launch my app on real device with signing ? I don't want to make a new release for test appinvite. – Oleksandr.D Mar 28 '16 at 08:10
  • The error said `... No Android client ID is found for package name ...`, are you sure you have entered _correct_ **package name** in your project's OAuth Client ID? Yes it will work just fine, I have tested it on my J5 on debug version and Alpha APK on Google Play Developer Console. – simplebe Mar 28 '16 at 08:18
  • Are you also sure it's your `OAuth Client ID`, **not** `API Key` as described [here](http://stackoverflow.com/a/36118171/3273872)? – simplebe Mar 28 '16 at 08:29
  • Yes, because the name is "Android client for (auto created by Google Service)" – Oleksandr.D Mar 28 '16 at 08:31
  • simplebe, I was delete a OAuth and create new. But it doesn't help me. – Oleksandr.D Mar 28 '16 at 09:21
0

I think that it should work automatically, if you have connected your Firebase with your app on Google Play, but you have to download your application from Google Play. I had the same problem and it didn't work in my case, because I had the version of an application which I installed straight from the computer (debug mode).

Piotr Sagalara
  • 2,247
  • 3
  • 22
  • 25