question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] [Dynamic Links] Dynamic Links callback in Kotlin incorrectly marked as non-null

See original GitHub issue

[READ] Step 1: Are you in the right place?

Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:

  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Android Studio version: Arctic Fox 2020.3.1 patch 2
  • Firebase Component: Dynamic Links KTX
  • Component version: 20.1.1

[REQUIRED] Step 3: Describe the problem

When running the sample code for Dynamic Links in Kotlin, the result of the addOnSuccessListener is not correctly marked as a nullable type, despite it being possible to return as null.

Steps to reproduce:

  • Follow the sample code setup in Kotlin
  • Call the sample code with an intent that doesn’t return pendingDynamicLinkData
  • Observe that null is returned for the non-nullable type param of the success callback

Relevant Code:

Firebase.dynamicLinks
        .getDynamicLink(intent)
        .addOnSuccessListener(this) { pendingDynamicLinkData ->

            // **BUG** Android Studio reports this check to always be true
            //  as the typing of pendingDynamicLinkData is not nullable
            if (pendingDynamicLinkData != null) {
               // some code here ...
            }
        }
        .addOnFailureListener(this) { e -> Log.w(TAG, "getDynamicLink:onFailure", e) }

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:21 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
atulgptcommented, Dec 10, 2021

Hi, @kazougagh is somehow you are making null type into not null type as Kotlin assert that parameter should not be null when type parameter is not-nullable. Can you modify the code as below to see if it still crashes or not

private fun handleDynamicsLink() {
        Firebase.dynamicLinks
            .getDynamicLink(intent)
            .addOnSuccessListener(this) { pendingDynamicLinkData: PendingDynamicLinkData? ->
                // Get deep link from result (may be null if no link is found)
                var deepLink: Uri? = null
                if (pendingDynamicLinkData != null) {
                    deepLink = pendingDynamicLinkData.link
                }
                if (deepLink != null) {
                    handleDeepLink(pendingDynamicLinkData.link!!)
                }
            }
            .addOnFailureListener(this) { e -> PemLog.e("MainActivity - getDynamicLink:onFailure", e) }
    }
3reactions
Naoki-pngcommented, Dec 28, 2021

You can solve this problem by adding these dependencies.

implementation 'com.google.android.gms:play-services-base:18.0.1'
implementation 'com.google.android.gms:play-services-tasks:18.0.1'

https://developers.google.com/android/guides/releases#december_16_2021

Read more comments on GitHub >

github_iconTop Results From Across the Web

Receive Firebase Dynamic Links on Android - Google
To receive the Firebase Dynamic Links that you created, you must include the Dynamic Links SDK in your app and call the FirebaseDynamicLinks....
Read more >
Firebase Dynamic Links created dynamically don't work Android
OK, after a while, I find the problem and it was totally JAVA issue: when I send dynamic link from android, I chain...
Read more >
Spring Data R2DBC - Reference Documentation
Follow the links in the release notes section to find the version that you want ... To create a query method that supports...
Read more >
Core - Android Developers
registerGnssMeasurementsCallback to work around Android R bugs. ... now includes the onPrepareMenu() callback, which is called when a menu is dynamically ...
Read more >
JUnit 5 User Guide
The links below highlight some of the combinations you can choose from. ... Denotes that a method is a test factory for dynamic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found