Illegal argument

Hi there,
I am getting an illegal argument exception if I use the following code. (See attachment)
I already gave my app permission to go on the internet in the manifest file. I also created a DefaultCallback and InitializeBackendless class. Within the InitializeBackendless class I have entered the App ID and the API key it still gave me an error. (See attachment for output). I have commented out the code I attached and I do not get an exception. That is how I know the exception was given from that code. Do you have any ideas what I can do to fix it?
Here is a background of what happened:
Due to permission problems on my pc I had to recreate the application and I also deleted the project from backendless to recreate it. I changed the App ID and API Key in my project from the old key. The ID and the Key is new. I know the problem is not there.

Hi Rhinwen,

Is it a Java or Android app? Where do you have Backendless.initApp call?

The application is an android app. And I am calling the Backendless.initApp within my InitializeBackendless.java class. And I have add backendless in my gradle (Module: app)

InitializeBackendless.PNG

Try calling UserIdStorageFactory.instance().init( Context ) before your .loggedInUser() call.

Hi it still gives me the same error. By the way where can I read up on the code you gave me? I want to know what it does. I tried here but do not understand the way they present it.

Please prepare a minimal verifiable sample so that we could reproduce the problem.

Hi I solved the Issue. Thank you for the help.

What was the problem?

I initialized Backendless in another class using the onCreate method. That worked in the past tho. I just initialized it before the code in the same class instead.

Before:

            Backendless.UserService.isValidLogin( new DefaultCallback<Boolean>( LoginScreen.this )
            {
                @Override
                public void handleResponse( Boolean isValidLogin )
                {
                    if( isValidLogin && Backendless.UserService.CurrentUser() == null )
                    {
//                        UserIdStorageFactory.instance().init( LoginScreen.this );
                        String currentUserId = Backendless.UserService.loggedInUser();


                        if( !currentUserId.equals( "" ) )
                        {
                            Backendless.UserService.findById( currentUserId, new DefaultCallback<BackendlessUser>( LoginScreen.this, "Logging in..." )
                            {
                                @Override
                                public void handleResponse( BackendlessUser currentUser )
                                {
                                    super.handleResponse( currentUser );
                                    Backendless.UserService.setCurrentUser( currentUser );
                                    startActivity( new Intent( getBaseContext(), Welcome_Screen.class ) );
                                    finish();
                                }
                            } );
                        }
                    }


                    super.handleResponse( isValidLogin );
                }
            });

//AFTER:

Backendless.setUrl(InitializeBackendLess.Server_URL);
            Backendless.initApp(LoginScreen.this,InitializeBackendLess.App_ID,InitializeBackendLess.API_Key);




            Backendless.UserService.isValidLogin( new DefaultCallback<Boolean>( LoginScreen.this )
            {
                @Override
                public void handleResponse( Boolean isValidLogin )
                {
                    if( isValidLogin && Backendless.UserService.CurrentUser() == null )
                    {
//                        UserIdStorageFactory.instance().init( LoginScreen.this );
                        String currentUserId = Backendless.UserService.loggedInUser();


                        if( !currentUserId.equals( "" ) )
                        {
                            Backendless.UserService.findById( currentUserId, new DefaultCallback<BackendlessUser>( LoginScreen.this, "Logging in..." )
                            {
                                @Override
                                public void handleResponse( BackendlessUser currentUser )
                                {
                                    super.handleResponse( currentUser );
                                    Backendless.UserService.setCurrentUser( currentUser );
                                    startActivity( new Intent( getBaseContext(), Welcome_Screen.class ) );
                                    finish();
                                }
                            } );
                        }
                    }


                    super.handleResponse( isValidLogin );
                }
            });