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)
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.
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...
来源:https://stackoverflow.com/questions/45372897/com-google-android-gms-common-api-apiexception-while-making-shorturl