cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

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

swright1512
Explorer | Level 3

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 2

Greg-DB
Dropbox Staff
Can you share the full error message and stack trace for the crash? Thanks in advance!

swright1512
Explorer | Level 3

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.

 

 

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    swright1512 Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?