'java.lang.String com.dropbox.core.DbxRequestConfig.getUserLocale()' on a null object reference
Login with dropbox account I got crash. implementation 'com.dropbox.core:dropbox-core-sdk:4.0.1' Api level 30
My Code :
public class DbxRequestConfigFactory {
private static DbxRequestConfig sDbxRequestConfig;
public static DbxRequestConfig getRequestConfig() {
if (sDbxRequestConfig == null) {
sDbxRequestConfig = DbxRequestConfig.newBuilder("myapp-dropbox-v2")
.withHttpRequestor(new OkHttp3Requestor(OkHttp3Requestor.defaultOkHttpClient()))
.build();
}
return sDbxRequestConfig;
}
}
Auth.startOAuth2PKCE(this, getString(R.string.app_key),DbxRequestConfigFactory.getRequestConfig());
Logs below
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:399) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.dropbox.core.DbxRequestConfig.getUserLocale()' on a null object reference at com.dropbox.core.DbxPKCEManager.makeTokenRequest(DbxPKCEManager.java:107) at com.dropbox.core.android.AuthActivity$TokenRequestAsyncTask.doInBackground(AuthActivity.java:793) at com.dropbox.core.android.AuthActivity$TokenRequestAsyncTask.doInBackground(AuthActivity.java:782) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919)
Thanks for the report. I just tried running this code with the same Dropbox SDK version and Android API level you mentioned, but the exception doesn't occur for me. Can you double check the version of the SDK you have installed, and that this is the exact code you're running when this occurs? Also, can you check the value returned by DbxRequestConfigFactory.getRequestConfig() at that point in the debugger?
I am facing the same issue. Have you found a solution yet??
Dropbox-SDK 4.0.0 Android 8.1, 10, 11
I have recieved following crash report in crashlytics
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$4.done(AsyncTask.java:399) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383) at java.util.concurrent.FutureTask.setException(FutureTask.java:252) at java.util.concurrent.FutureTask.run(FutureTask.java:271) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919)
Caused by java.lang.NullPointerException: Attempt to read from field 'java.lang.String j4.l.b' on a null object reference at com.dropbox.core.DbxRequestConfig.getUserLocale(DbxRequestConfig.java:110) at com.dropbox.core.DbxPKCEManager.makeTokenRequest(DbxPKCEManager.java:107) at com.dropbox.core.android.AuthActivity$TokenRequestAsyncTask.doInBackground(AuthActivity.java:793) at com.dropbox.core.android.AuthActivity$TokenRequestAsyncTask.doInBackground(AuthActivity.java:782) at android.os.AsyncTask$2.call(AsyncTask.java:333) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)
is this issue fixed in v5.0.0??
@CMTRehan We weren't able to reproduce the issue originally reported here, and we haven't heard back from the original commenter, so I don't have any information to add to this.
Your error message looks slightly different than the original one, but as a best practice I do recommend upgrading to the latest version of the SDK anyway, currently v5.0.0. If you're still seeing the issue with that, please share the necessary steps and code to reproduce the issue so we can look into it.
An Android app initiates the OAuth sequence by calling one of the methods startOAuth... in the com.dropbox.core.android.Auth class. What happens next:
-
Auth.startOAuth...()stores auth params in static fields ofAuthActivityclass, usingAuthActivity.setAuthParams(). That includesAuthActivity.sRequestConfig -
An instance of
AuthActivityclass is created by Android, itsonCreate()method is called, instance fieldmRequestConfigis set tosRequestConfig -
This instance of
AuthAcitivtycallsstartActivity()and passes control to Dropbox app or web browser. It also resets the auth params by callingsetAuthParams(null, null, null). This sets the static fieldsRequestConfig = null -
Dropbox app (or browser) passes the OAuth token back to our app. The method
AuthActivity.onNewIntentis supposed to capture and parse this OAuth token.
The problem is the AuthActivity instance at step 3 may not be the same instance created at step 1. Android is free to kill and re-create activities as it wishes. It's quite easy to reproduce such a situation. Between step 2 and step 3 when we are in the browser or Dropbox app, rotate the device to change its screen orientation. Then tap on "Allow" button.
Android now wants to go back to AuthActivity, but it cannot reuse the existing AuthActivity instance because the screen orientation changed. It discards the old instance and creates a new one, call its onCreate() method which sets mRequestConfig to sRequestConfig which is null........ CRASH
The sample Android app in Dropbox SDK has this in its AndroidManifest.xml:
<activity
android:name="com.dropbox.core.android.AuthActivity"
android:configChanges="orientation|keyboard"
...
It tries to prevent re-creation of the activity with android:configChanges="orientation|keyboard". This is bad practice and does not always work. I can reliably cause the crash even with this property set by rotating my Android 12 phone.
@tdtran Thanks for the detailed message! That's very helpful. We'll look into it.
Still happening on 5.2.0, though probably fairly rare. Seen reported on a Samsung Android 12 device:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.dropbox.core.DbxRequestConfig.getUserLocale()' on a null object reference
at com.dropbox.core.DbxPKCEManager.makeTokenRequest(DbxPKCEManager.java:107)
at com.dropbox.core.android.AuthActivity$TokenRequestAsyncTask.doInBackground(AuthActivity.java:793)
at com.dropbox.core.android.AuthActivity$TokenRequestAsyncTask.doInBackground(AuthActivity.java:782)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
@bubbleguuum Thanks for the note! This is still open with the team.
I can confirm it still happens on 5.3.0 =( . Please fix it.
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:381)
at java.util.concurrent.FutureTask.setException(FutureTask.java:250)
at java.util.concurrent.FutureTask.run(FutureTask.java:269)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.dropbox.core.DbxRequestConfig.getUserLocale()' on a null object reference
at com.dropbox.core.DbxPKCEManager.makeTokenRequest(DbxPKCEManager.java:107)
at com.dropbox.core.android.AuthActivity$TokenRequestAsyncTask.doInBackground(AuthActivity.java:793)
at com.dropbox.core.android.AuthActivity$TokenRequestAsyncTask.doInBackground(AuthActivity.java:782)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
@kruil Thanks for the information. This is still open with the team, and I'll follow up here once I have an update on it.
Fixed in https://github.com/dropbox/dropbox-sdk-java/pull/443, will be releasing 5.4.0 by early next week.
Update: v5.4.2 is out with the fix for this. Please use that and let us know if you're still seeing any issues. Thanks!
Still crash on v5.4.2!!! Nothing changed.
@alexplanetart could you provide us with a stacktrace of the crash?
@devPalacio @alexplanetart - I see the stack traces from before. It walked through some of the flows and it looks like locale can be nullable. I can't address this immediately because I'm out of town, but can get this in a patch version soon.
Sorry, I thought this nullability was handled in the Kotlin conversion, but it wasn't because it's a nested property.
Will get to this and get a fix early next week. Cheers.
@devPalacio

@handstandsam @devPalacio
The latest version 5.4.2 seems to have ANR problem. This problem did not occur in the previous version, although it only happened once now. Please check the reason for this problem.
