Skip to content
Back

FATAL EXCEPTION NullPointerException: null cannot be cast to non-null type kotlin

  • 0
  • Self Hosted
  • Android
mane
4 Aug, 2025, 07:50

Hi

I'm using your SDK in my Android app... i upgraded to io.appwrite:sdk-for-android:8.1.0 and now i'm getting the following errors on Appwrite servers with older versions like 1.4.3:

TypeScript
                                                                               Process: com.xxx.xxx, PID: 17591
                                                                               java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Boolean
                                                                                   at io.appwrite.models.User$Companion.from(User.kt:210)
                                                                                   ..```
                                                                                
```09:40:20.275 18366-18455 AndroidRuntime          com.xxx.xxx      E  FATAL EXCEPTION: OkHttp Dispatcher (Ask Gemini)
                                                                               Process: com.xxx.xxx, PID: 18366
                                                                               java.lang.NullPointerException: null cannot be cast to non-null type kotlin.String
                                                                                   at io.appwrite.models.Session$Companion.from(Session.kt:225)
                                                                                   ..```

I think it has to do with new fields that are actually null in 1.4.3 right?

Thanks
TL;DR
Developers encountered NullPointerException issues after upgrading to io.appwrite:sdk-for-android:8.1.0 when using Appwrite servers with older versions like 1.4.3, with errors indicating casting issues with null fields. The solution is to ensure compatibility by matching Appwrite versions: `8.x` with Appwrite `1.7.x`, `7.x` with `1.6.x`, etc. This mismatch causes the NullPointerException errors.
mane
4 Aug, 2025, 07:51
TypeScript
                                                                               Process: com.xxx.xxx, PID: 17591
                                                                               java.lang.NullPointerException: null cannot be cast to non-null type kotlin.Boolean
                                                                                   at io.appwrite.models.User$Companion.from(User.kt:210)
                                                                                   at io.appwrite.services.Account$get$converter$1.invoke(Account.kt:38)
                                                                                   at io.appwrite.services.Account$get$converter$1.invoke(Account.kt:36)
                                                                                   at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:602)
                                                                                   at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
                                                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
                                                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651)
                                                                                   at java.lang.Thread.run(Thread.java:1119```
mane
4 Aug, 2025, 07:51
TypeScript
                                                                               Process: com.xxx.xxx, PID: 18366
                                                                               java.lang.NullPointerException: null cannot be cast to non-null type kotlin.String
                                                                                   at io.appwrite.models.Session$Companion.from(Session.kt:225)
                                                                                   at io.appwrite.services.Account$createEmailPasswordSession$converter$1.invoke(Account.kt:1050)
                                                                                   at io.appwrite.services.Account$createEmailPasswordSession$converter$1.invoke(Account.kt:1048)
                                                                                   at io.appwrite.Client$awaitResponse$2$1.onResponse(Client.kt:602)
                                                                                   at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519)
                                                                                   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1156)
                                                                                   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:651)
                                                                                   at java.lang.Thread.run(Thread.java:1119)```
Darshan Pandya
4 Aug, 2025, 07:53

8.x is compatible with Appwrite 1.7.x. 7.x with 1.6.x and so on. https://github.com/appwrite/sdk-for-android/releases

mane
4 Aug, 2025, 07:57

Thanks Darshan.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more