Issue
private fun getReferralId() {
Firebase.dynamicLinks
.getDynamicLink(intent)
.addOnSuccessListener(this) { pendingDynamicLinkData ->
pendingDynamicLinkData?.link?.getQueryParameter(
DEEP_LINK_QUERY_PARAM_REFERRAL_ID
)?.let { refId ->
viewModel.saveReferralId(refId)
}
}
}
java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter pendingDynamicLinkData at app.package.activity.MainActivity.getReferralId$lambda-2(Unknown Source:7) at app.package.activity.MainActivity.$r8$lambda$ANLS0uCuXrQe7RFQ5b0C-RFsBKE(Unknown Source:0) at app.package.activity.MainActivity$$ExternalSyntheticLambda3.onSuccess(Unknown Source:4)
version:
implementation platform("com.google.firebase:firebase-bom:28.3.1")
implementation "com.google.firebase:firebase-dynamic-links-ktx"
What is wrong here?
UPDATE
It happens when I update version of play-services-auth libs
implementation "com.google.android.gms:play-services-auth:19.2.0"
implementation "com.google.android.gms:play-services-auth-api-phone:17.5.1"
to newest version
implementation "com.google.android.gms:play-services-auth:20.0.0"
implementation "com.google.android.gms:play-services-auth-api-phone:18.0.0"
How is that even related?
Solution
it's a bug in the library due to a play services update. To fix it, you should explicitly declare that the pendingDynamicLinkData
is nullable.
Like this:
private fun getReferralId() {
Firebase.dynamicLinks
.getDynamicLink(intent)
.addOnSuccessListener(this) { pendingDynamicLinkData: PendingDynamicLinkData? ->
pendingDynamicLinkData?.link?.getQueryParameter(
DEEP_LINK_QUERY_PARAM_REFERRAL_ID
)?.let { refId ->
viewModel.saveReferralId(refId)
}
}
}
Answered By - brwngrldev