# Attempt to invoke virtual method 'EkoPushContractWrapper.getPushContract()' on a null object reference

**URL:** <https://forum.social.plus/t/attempt-to-invoke-virtual-method-ekopushcontractwrapper-getpushcontract-on-a-null-object-reference/1417>\
**Category:** Android\
**Created:** [August 12, 2024, 10:00am UTC](https://forum.social.plus/t/attempt-to-invoke-virtual-method-ekopushcontractwrapper-getpushcontract-on-a-null-object-reference/1417 "2024-08-12T10:00:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![m445](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@m445](https://forum.social.plus/u/m445)\
**Post date:** [August 12, 2024, 10:00am UTC](https://forum.social.plus/t/attempt-to-invoke-virtual-method-ekopushcontractwrapper-getpushcontract-on-a-null-object-reference/1417/1 "2024-08-12T10:00:26Z")

</div>

Hello, we are experiencing crashes for some users when Firebase `onNewToken` is triggered. Our implementation is similar to what can be found in samples in `AmitySampleFirebaseMessagingService` and looks like this:

```auto
    override fun onNewToken(token: String) {
        AmityFcm.create()
            .setup(token)
            .subscribe(
                { Timber.i("fcm_new_token onNewToken success") },
                { Timber.e("fcm_new_token onNewToken: $it error") },
            )
    }

```

and for some users we are experiencing NullPointers

```auto
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'com.amity.socialcloud.sdk.push.EkoPushContract com.amity.socialcloud.sdk.push.EkoPushContractWrapper.getPushContract()' on a null object reference
       at com.amity.socialcloud.sdk.push.AmityFcm.setup(AmityFcm.java:24)

```

Most crashes are marked as Early crashes on Crashlytic meaning they occur within 5s from app startup. Any idea what can be reason of having null **EkoPushContractWrapper**?

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [August 12, 2024, 10:30am UTC](https://forum.social.plus/t/attempt-to-invoke-virtual-method-ekopushcontractwrapper-getpushcontract-on-a-null-object-reference/1417/2 "2024-08-12T10:30:32Z")

</div>

Hello @m445, could you please let us know your current Android SDK/UIkit versions?

Additionally, did this issue just start occurring, or did it begin after you updated to the version?

---

<div class="post-metadata">

**Author:** ![m445](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@m445](https://forum.social.plus/u/m445)\
**Post date:** [August 12, 2024, 11:57am UTC](https://forum.social.plus/t/attempt-to-invoke-virtual-method-ekopushcontractwrapper-getpushcontract-on-a-null-object-reference/1417/3 "2024-08-12T11:57:55Z")

</div>

We forked android UIkit with version **3.1.0**. Our current Amity messaging service is **6.16.1**. Issue happens from the beginning, we have updated amity for a while

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [August 12, 2024, 1:05pm UTC](https://forum.social.plus/t/attempt-to-invoke-virtual-method-ekopushcontractwrapper-getpushcontract-on-a-null-object-reference/1417/4 "2024-08-12T13:05:44Z")

</div>

@m445 thank you for confirming - let us pass to the team to further check.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [August 13, 2024, 11:26am UTC](https://forum.social.plus/t/attempt-to-invoke-virtual-method-ekopushcontractwrapper-getpushcontract-on-a-null-object-reference/1417/5 "2024-08-13T11:26:34Z")

</div>

Hello @m445, this error may occur if the `AmityCoreClient.setup()` process hasn’t been fully completed.

We recommend checking the implementation of `AmityCoreClient.setup()`. To prevent race conditions, please ensure that `AmityCoreClient.setup()` should be called once in Application class.
