3

I'm using firebase dynamic links, when I'm trying to getShortLink its crashing with FATAL EXCEPTION called com.google.android.gms.common.api.ApiException please help me Here is my code

private void buildReferralLink() {
    //https://j8b99.app.goo.gl/
    String domain = "j8b99" + ".app.goo.gl";

    DynamicLink.Builder builder = FirebaseDynamicLinks.getInstance()
            .createDynamicLink()
            .setDynamicLinkDomain(domain)
            .setAndroidParameters(new DynamicLink.AndroidParameters.Builder()
                    .setMinimumVersion(BuildConfig.VERSION_CODE)
                    .build())
            .setLink(Uri.parse("https://play.google.com/store/apps/details?id=com.games4playstore.aroundyou"));

    builder.buildShortDynamicLink().addOnCompleteListener(this, new OnCompleteListener<ShortDynamicLink>() {
        @Override
        public void onComplete(@NonNull Task<ShortDynamicLink> task) {
            Uri shortLink = task.getResult().getShortLink();
            Log.e("test", "ShortLink: " + shortLink);
        }
    });
}

Here is my crash report

07-28 17:19:22.526 21231-21231/com.games4playstore.aroundyou E/AndroidRuntime: FATAL EXCEPTION: main
                                                                           Process: com.games4playstore.aroundyou, PID: 21231
                                                                           com.google.android.gms.tasks.RuntimeExecutionException: com.google.android.gms.common.api.ApiException
                                                                               at com.google.android.gms.tasks.zzn.getResult(Unknown Source)
                                                                               at com.games4playstore.aroundyou.MainActivity$3.onComplete(MainActivity.java:160)
                                                                               at com.google.android.gms.tasks.zzf.run(Unknown Source)
                                                                               at android.os.Handler.handleCallback(Handler.java:739)
                                                                               at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                               at android.os.Looper.loop(Looper.java:145)
                                                                               at android.app.ActivityThread.main(ActivityThread.java:6946)
                                                                               at java.lang.reflect.Method.invoke(Native Method)
                                                                               at java.lang.reflect.Method.invoke(Method.java:372)
                                                                               at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
                                                                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
                                                                            Caused by: com.google.android.gms.common.api.ApiException
                                                                               at com.google.android.gms.internal.zzbeq.zza(Unknown Source)
                                                                               at com.google.android.gms.internal.zg.zza(Unknown Source)
                                                                               at com.google.android.gms.internal.zl.onTransact(Unknown Source)
                                                                               at android.os.Binder.execTransact(Binder.java:446)
Suresh
  • 427
  • 1
  • 6
  • 22
  • Is this happening consistently? The best thing to do would be to file a ticket with https://firebase.google.com/support/contact/troubleshooting/ and include your project details, they'll be able to investigate more. – Ian Barber Jul 28 '17 at 22:51

2 Answers2

5

This was an issue on the server side with Dynamic Links on Android - it has been resolved and the fix should be rolling out soon.

Ian Barber
  • 19,765
  • 3
  • 58
  • 58
2

I'm getting the same error. The code worked fine earlier this week.

According to this link, the exception is returned by a Task when a call to Google Play services has failed. My first thought was to ensure that I am referencing the latest builds (which seems to be 11.0.4 as at the time of writing this) in my Gradle file, but that made no difference.

The error shows no additional information other than the ApiException. I've gone through the Firebase Dynamic Link setup steps again but can't see anything odd. I'll next try to see if there is a problem with Google Play services.

As I said, my code (similar to yours) generated links fine two days ago. Very odd...

MacMc
  • 111
  • 5
  • it happened for me as well so I am not sure what I am going to do since I have to upload a new version and this feature is milestone for me – Fadel Sabbagh Jul 28 '17 at 19:05
  • Is there any chance you have very long links? There have been some reports of errors where the link field is long (2000+ characters) – Ian Barber Jul 28 '17 at 22:52
  • @IanBarber I have a similar problem with 11.2.0 version any expected ETA for fix -> https://stackoverflow.com/questions/45826742/cant-create-short-firebase-dynamic-link-dynamic-link-error-7-forbidden – Pablo A. Martínez Aug 23 '17 at 12:02