Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I have an android application which has been working perfectly until now. Recently, I'm having an error regarding the dropbox download. I've been using this app and the dropbox download for months but I never had this error yet. I tried to solve it but I found nothing similar. Is something wrong with dropbox or I made some mistake?
My question is why dirent = dropboxAPI.metadata("/", 1000, null, true, null);
dirent becomes null?
Thanks very much in advance!
Code
public void downAndLoad() { AsyncTask<String, Void, Void> asyncTask = new AsyncTask<String, Void, Void>() { @Override@Override protected Void doInBackground(String... strings) { AndroidAuthSession session = null; try { session = buildSession(); } catch (DropboxException e) { e.printStackTrace(); } dropboxAPI = new DropboxAPI<>(session); String[] fnames = null; DropboxAPI.Entry dirent = null; try { dirent = dropboxAPI.metadata("/", 1000, null, true, null); } catch (DropboxException e) { e.printStackTrace(); } }
Error:
10-01 00:31:08.963 11769-11961/com.example.brobert.tonda E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #4 Process: com.example.brobert.tonda, PID: 11769 java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:318) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762) Caused by: java.lang.NullPointerException: Attempt to read from field 'java.util.List com.dropbox.client2.DropboxAPI$Entry.contents' on a null object reference at com.example.brobert.tonda.dldb_lp$1.doInBackground(dldb_lp.java:149) at com.example.brobert.tonda.dldb_lp$1.doInBackground(dldb_lp.java:126) at android.os.AsyncTask$2.call(AsyncTask.java:304) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:762)
[Cross-linking for reference: https://stackoverflow.com/questions/46531209/dropboxapi-metadata-1000-null-true-null-is-null ]
The SDK you're using uses API v1. As announced last year, API v1 has been retired. You can find more information in the blog post here:
https://blogs.dropbox.com/developers/2016/06/api-v1-deprecated/
Now that API v1 has been retired, further API calls to it will fail. You should migrate your app to API v2 instead:
https://github.com/dropbox/dropbox-sdk-java
For reference though, it appears your `dirent` is `null` because you initialize it to `null`, and the `metadata` call now fails because API v1 is retired. Your code catches any `DropboxException` from `metadata` only prints the stack trace, allowing your code execution to continue, using the `dirent` which is still `null`, since `metadata` didn't return.
If you need more time to migrate your app to API v2, we can offer an extension for access to API v1. To request that, please open an API ticket with the relevant app key(s):
Could you tell me if it's possible like in the v1 that the user doesn't need to login in his/her dropbox accoount, s/he can download from MY dropbox in the android application? Because it was possible in v1 and not possible by google drive
Thanks
Thanks for your quick answer. I tell you what I did and would like to do and if you have a better idea please let me know:
I have an android application which does the following: When a user presses a button in the app, it creates ssh connection with my raspberry pi which creates some files and uploads them to my dropbox account.
Until stopping v1, my application searched for the latest file that got uploaded to dropbox and downloaded it, but unfortuantely it's not working now. This is the best solution I could come up with.
Do you have a better idea (how to throw back the files on raspberry pi to my app)?
Thanks
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
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!