Start a new topic

Android user signup issues...

Trying to set up User Signup on Android. Couple of issues that I'm facing:


1.   In the kinvey.properties file, it has:

            app.key=your_kinvey_app_id

            app.secret=your_kinvey_app_secrt


             Do I need quotation marks on either side of my app id and app secret? Or do I                just paste them right after the = sign?


2. It says "// Enter your app credentials here" in the initialize() method in the UserLogin.java class. Which credentials are those and where do I enter them exactly?


3. I'm getting a null pointer exception on the line "service = new Client.Builder(this).build();" in that UserLogin.java class. My class is the exact same as Kinvey's sample Sign In app. I get "java.lang.RuntimeException: Unable to create application xxxxxx.KinveyMobile.UserLogin: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream java.net.URL.openStream()' on a null object reference"



Any thoughts on way that's happening? I'm not sure




Hi Langdon,


To answer your questions,

  1. Quotation marks are not required. Just paste them as it is.
  2. If you have entered app credentials in properties file (app key and app secret), then you don't need to enter those credentials anywhere. In login calls, you will need to enter username and password of the user.
  3. The build function call should be something as stated below. Have you tried that?

 

final Client mKinveyClient = new Client.Builder(this.getApplicationContext()).build();

 


If you are having trouble with code given in documentation guides available at http://devcenter.kinvey.com/android, please give us the specific links and topic headers. We'll take a look at how that can be simplified further.



Regards,

Wani

Kinvey documentation could be a whole lot better.


MainActivity is my launcher activity. After setting the content view, I run this initializing method:  

private void initializeKinvey() {
    final Client kinveyClient = new Client.Builder("xxxx-key-xxxxx", "xxxx-secret-, this.getApplicationContext()).build();

    kinveyClient.ping(new KinveyPingCallback() {
        public void onFailure(Throwable t) {
            Log.e(TAG, "Kinvey Ping Failed", t);
        }

        public void onSuccess(Boolean b) {
            Log.d(TAG, "Kinvey Ping Success");
        }
    });

}

  Then I check if the user's already logged in to Kinvey with this method:    

private boolean loggedIn() {
        AccountManager am = AccountManager.get(this);
        Account[] accounts = am.getAccountsByType(UserLogin.ACCOUNT_TYPE);
        if (accounts.length > 0) {
            Log.d(TAG, "loggedIn: accounts.length > 0");
            return true;
        } else {
            Intent intent = new Intent(MainActivity.this, LoginActivity.class);
            startActivity(intent);
            return false;
        }
    }

The following code for the service is in my manifest:  

 <service android:name=".KinveyMobile.KinveyAuthenticationService">
            <intent-filter>
                <action android:name="android.accounts.AccountAuthenticator"></action>
            </intent-filter>

            <meta-data
                android:name="android.accounts.AccountAuthenticator"
                android:resource="@xml/authenticator" />
        </service>

All of that said, I'm still getting that null pointer exception. I'm not sure what I'm doing wrong or if I'm doing things out of order....


Regarding #3 of our discussion, it looks like I'm making the build function when I use the key and the secret key, no? The Kinvey documentation about getting started is different than the Sign In sample app. The Sign In sample app doesn't appear to have much code from this page as well...

Login or Signup to post a comment