Forum Discussion

swright1512's avatar
swright1512
Explorer | Level 3
9 years ago

Migrate from V1 to V2 API Crash on DropboxClientFactory.init(accessToken);

Hello,

 

So first I removed from my android app all V1 API code.

 

I have an eclipse project.  I added all .jar files for V2 API 3.0.3 and dependencies.

 

I looked at the example (which has no comments).

 

So for now i have just placed all authentication into my OnResume. But it crashes when executing DropboxClientFactory.init(accessToken);

 

I start the App, open the settings and enable dropbox, this then passes message MESSAGE_AUTHENTICATE_DROPBOX which implements Auth.startOAuth2Authentication(BluetoothChat.this, APP_KEY) and i get the AuthActivity and I authorise, then onResume gets the access token and then it closes.

 

if i step through with the debugger then when  DropboxClientFactory.init(accessToken) is called the debugger jumps to super.onResume() and then the app closes.

 

Here is the onResume:-

 

 

@Override
public synchronized void onResume() {
  super.onResume();
  if(D) Log.e(TAG, "+ ON RESUME +");

  boolean dropBoxState=Prefs_DropBox; //Save Dropbox Prefs State before reload prefs

  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
  String accessToken = prefs.getString("access-token", null);
  if (accessToken == null) {
    accessToken = Auth.getOAuth2Token();
    if (accessToken != null) {
      prefs.edit().putString("access-token", accessToken).apply();
      prefs.edit().putBoolean("DropboxIntegration", true).commit();
      DropboxClientFactory.init(accessToken);
          PicassoClient.init(getApplicationContext(),com.dropbox.core.examples.android.DropboxClientFactory.getClient());
}
} else {
  DropboxClientFactory.init(accessToken);
  PicassoClient.init(getApplicationContext(), com.dropbox.core.examples.android.DropboxClientFactory.getClient());
}

if(D) Log.e(TAG, "LoadPrefs");
LoadPrefs();

if (Prefs_DropBox) {
  if (!dropBoxState) //Dropbox has just been enabled
  {
    mHandler.obtainMessage(MESSAGE_AUTHENTICATE_DROPBOX).sendToTarget();
    //Disable again until Authentication completes!
    prefs.edit().putBoolean("DropboxIntegration", false).commit();
}

}

 

2 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago
    Can you share the full error message and stack trace for the crash? Thanks in advance!
  • swright1512's avatar
    swright1512
    Explorer | Level 3
    9 years ago

    Greg,

     

    Thanks for getting back to me.  

     

    I think the crash i had was an ADB or Driver issue.  the authentication worked ok when i ran without the debugger.  

     

    I had not used my LG G6 to debug before.  I used the debugger with an old Motorolla E and it authenticated ok.  Maybe I need to update the android SDK.

     

    I now have authentication and AsyncTask that uploads all files matching a pattern for a given folder so I am now close to deprecating API V1 from my application.

     

     

     

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!