Start a new topic

#4271 Client null

 

 Hi,
my App is as simple as your example. I*ve just moved it into a new project:
now I do call the Build() funktion
Client.Builder cb = new Client.Builder(app_key, app_secret)
                //.setFilePath (NSFileManager.DefaultManager.GetUrls (NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User) [0].ToString ())
                .setFilePath(DependencyService.Get<ISQLite>().GetPath())
                .setOfflinePlatform(DependencyService.Get<ISQLite>().GetConnection());
cb.build();

But then in OnButtonClicked:
... if  (!Client.SharedClient.IsUserLoggedIn())

I get the error the Client is null.

I copied my key, secret, user and password from the test app which worked there

Please help.

@mark

After initiate client like this....


Client.Builder cb = new Client.Builder(app_key, app_secret); 

Client KinveyClient = cb.Build(); PingResponse response = await KinveyClient.PingAsync(); 

return KinveyClient;


throwing null exception from here

 DataStore<Comment> dataStore = DataStore<Comment>.Collection("TestComment", DataStoreType.SYNC);


did u able to add and push to kinvey ?

Hi,

Please try following code:

private async Task<Client> BuildClient()

       {

           Client.Builder cb = new Client.Builder(AppKey, AppSecret);

           KinveyClient = cb.Build();

           try

           {

               PingResponse response = await KinveyClient.PingAsync();

           }

           catch (Exception e)

           {

           }

           return KinveyClient;

       }


While calling this method please call it like this : await BuildClient() 
Also, Make sure you are using the correct values of your appkey and appsecret. Please try this and let us know if this works for you.

Regards,
Abhijeet

Thank you Abhijeet, it worked. But the solution was to install a newer sqlite package to the android project.
Please take a look at my follow up threads. It feels like I stumble about everything...

 

Hi Mark,

You will have to initialize the created client to something. E.g. please look at the code provided here. You will notice kinveyClient is assigned the value after the initialization.

Client kinveyClient = builder.Build();  //like this

After this please check if your connection is working with your backend. You can use Ping for that. After this please perform login of any one user and then check if the user is logged in. Please let us if this helps.

Regards,
Abhijeet


Hi, thanks for the answer.

With this code:

private async Task<Client> BuildClient()
        {
            Client.Builder cb = new Client.Builder(app_key, app_secret)
                //.setFilePath (NSFileManager.DefaultManager.GetUrls (NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User) [0].ToString ())
                .setFilePath(DependencyService.Get<ISQLite>().GetPath())
                .setOfflinePlatform(DependencyService.Get<ISQLite>().GetConnection());
            kinveyClient = cb.Build();
            try
            {
                PingResponse response = await kinveyClient.PingAsync();
            }
            catch (Exception e)
            {
                // an error has occured
            }
            return kinveyClient;
        }

I never reach "PingResponse response =....", but also never catch an exception on the outer function calling "BuildClient"


What is the problem? I used the same key, secret, user and password as before in the sample provided (books)

Where by the way the answer you gave here seemed not nessessary .

Thanks again

 

ollow up: In the output I found the following entries.

Of course I added the kinvey nuget package, which depends and automatically added the SQLite packages. It seems - although I do not catch the error - the error is within sql. 

What are my options?




10-29 13:51:18.584 D/Mono    ( 6740): DllImport attempting to load: 'libsqlite3_xamarin'.
10-29 13:51:18.585 D/Mono    ( 6740): DllImport error loading library '/storage/emulated/0/Android/data/PokerSheetz.Android/files/.__override__/libsqlite3_xamarin': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86//storage/emulated/0/Android/data/PokerSheetz.Android/files/.__override__/libsqlite3_xamarin" not found'.
10-29 13:51:18.588 D/Mono    ( 6740): DllImport error loading library '/storage/emulated/0/Android/data/PokerSheetz.Android/files/.__override__/libsqlite3_xamarin.so': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86//storage/emulated/0/Android/data/PokerSheetz.Android/files/.__override__/libsqlite3_xamarin.so" not found'.
10-29 13:51:18.588 D/Mono    ( 6740): DllImport error loading library '/system/lib/libsqlite3_xamarin': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86//system/lib/libsqlite3_xamarin" not found'.
10-29 13:51:18.588 D/Mono    ( 6740): DllImport error loading library '/system/lib/libsqlite3_xamarin.so': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86//system/lib/libsqlite3_xamarin.so" not found'.
10-29 13:51:18.589 D/Mono    ( 6740): DllImport error loading library 'libsqlite3_xamarin': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86/libsqlite3_xamarin" not found'.
10-29 13:51:18.589 D/Mono    ( 6740): DllImport error loading library 'libsqlite3_xamarin.so': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86/libsqlite3_xamarin.so" not found'.
10-29 13:51:18.590 D/Mono    ( 6740): DllImport error loading library 'libsqlite3_xamarin': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86/libsqlite3_xamarin" not found'.
10-29 13:51:18.590 W/Mono    ( 6740): DllImport unable to load library 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86/libsqlite3_xamarin" not found'.
10-29 13:51:18.592 D/Mono    ( 6740): DllImport attempting to load: 'libsqlite3_xamarin'.
10-29 13:51:18.595 D/Mono    ( 6740): DllImport error loading library '/storage/emulated/0/Android/data/PokerSheetz.Android/files/.__override__/libsqlite3_xamarin': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86//storage/emulated/0/Android/data/PokerSheetz.Android/files/.__override__/libsqlite3_xamarin" not found'.
10-29 13:51:18.597 D/Mono    ( 6740): DllImport error loading library '/storage/emulated/0/Android/data/PokerSheetz.Android/files/.__override__/libsqlite3_xamarin.so': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86//storage/emulated/0/Android/data/PokerSheetz.Android/files/.__override__/libsqlite3_xamarin.so" not found'.
10-29 13:51:18.597 D/Mono    ( 6740): DllImport error loading library '/system/lib/libsqlite3_xamarin': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86//system/lib/libsqlite3_xamarin" not found'.
10-29 13:51:18.597 D/Mono    ( 6740): DllImport error loading library '/system/lib/libsqlite3_xamarin.so': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86//system/lib/libsqlite3_xamarin.so" not found'.
10-29 13:51:18.598 D/Mono    ( 6740): DllImport error loading library 'libsqlite3_xamarin': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86/libsqlite3_xamarin" not found'.
10-29 13:51:18.599 D/Mono    ( 6740): DllImport error loading library 'libsqlite3_xamarin.so': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86/libsqlite3_xamarin.so" not found'.
10-29 13:51:18.599 D/Mono    ( 6740): DllImport error loading library 'libsqlite3_xamarin': 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86/libsqlite3_xamarin" not found'.
10-29 13:51:18.599 W/Mono    ( 6740): DllImport unable to load library 'dlopen failed: library "/data/app/PokerSheetz.Android-1/lib/x86/libsqlite3_xamarin" not found'.
10-29 13:51:18.775 D/Mono  

 

Login or Signup to post a comment