I recently updated my Android app to target and compile SDK version 35. After this migration, I'm encountering a runtime crash related to Firebase Dynamic Links.
Here’s the stack trace:
java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.tasks.Task com.google.firebase.dynamiclinks.FirebaseDynamicLinks.getDynamicLink(android.content.Intent)' on a null object reference
at com.jazz.jazzworld.presentation.ui.main.MainActivity.dynamicLinks(MainActivity.kt:645)
at com.jazz.jazzworld.presentation.ui.main.MainActivity.processToDynamicLink(MainActivity.kt:635)
at com.jazz.jazzworld.presentation.ui.main.MainActivity.onCreate(MainActivity.kt:140)
at android.app.Activity.performCreate(Activity.java:8886)
at android.app.Activity.performCreate(Activity.java:8851)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1467)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3966)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4137)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:99)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2601)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:222)
at android.os.Looper.loop(Looper.java:314)
at android.app.ActivityThread.main(ActivityThread.java:8610)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:565)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
The crash happens when I attempt to handle dynamic links in my app.
private fun dynamicLinks() {
if (intent != null) {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(intent)
.addOnSuccessListener(this) { pendingDynamicLinkData ->
Logger.errorLog("TAG_DYNAMIC_LINK", "on success")
}
.addOnFailureListener(this) { e ->
Logger.errorLog("TAG_DYNAMIC_LINK", e.message ?: "")
}
}
}
The code used to work perfectly before migrating to API level 35 and Gradle version 8.7 . This was working fine on the previous Gradle version. I have verified that Firebase dependencies are properly included in my build.gradle:
implementation platform('com.google.firebase:firebase-bom:33.3.0') //33.1.1
implementation 'com.google.firebase:firebase-dynamic-links-ktx'
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-config-ktx'
implementation 'com.google.firebase:firebase-perf-ktx'
What I've Tried:
- Rechecked the Firebase setup in the google-services.json.
- Updated all Firebase libraries to their latest versions.
- Verified that the dynamic link logic works fine on lower API levels.
- Cleaned and rebuilt the project.
- Ensured that the FirebaseDynamicLinks object is initialized properly.
However, the issue persists after the migration to API level 35.
Has anyone else encountered this issue after migrating to API 35? Could there be changes in the new API level that might affect Firebase Dynamic Links? Any help would be appreciated!