Back

[SOLVED] Error when import java + kotlin sdk

  • 1
  • Android
  • Tools
retr122
29 Jun, 2023, 16:54

If I don't finally find solution I'll send code here

TL;DR
The user was experiencing an error when importing the Java and Kotlin SDK. They needed to put the code in an AsyncTask because the app was lagging. They added a boolean variable to delete the session when true. However, they wanted to do this only outside the "account.create()" method and start the code after it fully compiles. They were catching the error twice because the code was starting compilation when the account and session were created. They mentioned that the newSessionId value was null when going outside the createEmailSession method, causing an error in the first code variation. They also discussed the usage of storing the session ID in SharedPreferences.
retr122
29 Jun, 2023, 16:54

I need to learn more

retr122
29 Jun, 2023, 17:07
retr122
29 Jun, 2023, 17:08

It returns two io.appwrite.exceptions.AppwriteException: User (role: guests) missing scope (account)

Drake
29 Jun, 2023, 17:54

why?

Drake
29 Jun, 2023, 17:55

This typically happens when you don't have a session which makes sense because you're calling account.getSession() before a session is created

retr122
29 Jun, 2023, 17:57

In first situation sessionId string is not founded in debug and that's why it don"t work

retr122
29 Jun, 2023, 17:57

I need to call deleteSession later?

Drake
29 Jun, 2023, 18:01

no.

Drake
29 Jun, 2023, 18:02

when you create a session, you get a session id. or you can call getSession. i don't really understand why you need to store it in shared preferences

retr122
29 Jun, 2023, 18:03

....

retr122
29 Jun, 2023, 18:03

String newSessionId is getting value from createEmailSession()

retr122
29 Jun, 2023, 18:04

But when I going outside createEmailSession newSessionId value is null and catch's error in first code variation

Drake
29 Jun, 2023, 18:32

Of course

retr122
30 Jun, 2023, 17:08

I finally understand why problem here

retr122
30 Jun, 2023, 17:09

In my code first instruction is account.create()

retr122
30 Jun, 2023, 17:09

In account.create() other data saving code

retr122
30 Jun, 2023, 17:09

But this code start compilation when account and Session created

retr122
30 Jun, 2023, 17:10

But account.getSession() and account.deleteSession() starts work right now

retr122
30 Jun, 2023, 17:10

And this is why i catch this error twice

retr122
30 Jun, 2023, 17:11

I need to start this code only after account.create() full compilation

retr122
30 Jun, 2023, 17:13

But I need to do it only outside account.create() method

retr122
30 Jun, 2023, 17:26

I solved this! I add boolean and when boolean == true session deletes

retr122
30 Jun, 2023, 17:26

But I need to put it in AsyncTask because app is lagged when account creates

retr122
30 Jun, 2023, 17:27

[SOLVED] Error when import java + kotlin sdk

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