Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
AppDev
8 years agoExplorer | Level 3
Get a list of files from dropbox to android application
Hi everybody, I'm new to dropbox developing and I need help with it please. I wrote an android application that needs to get a list of files listing in dropbox. I used the tutorial and part of the co...
Greg-DB
Dropbox Community Moderator
8 years agoFirst, for reference, unless there is a particular reason you need to process the authorization every time, you can store and re-use access tokens, e.g., as done in the example here.
Anyway, are you using Android Studio? If so, there's a "Logcat" tab where you can selected the relevant device and thread (though they should be automatically selected for you by default) and see the output/stack trace for an exception.
Also, you don't need to add the jar manually. We recommend having your package manager download and install it automatically, as shown here.
AppDev
8 years agoExplorer | Level 3
Hi Greg,
I don't know if I understood you correctly... I'm using Android Studio.
On SDK Manager --> SDK Update Sites I added DropBox SDK and the path https://github.com/dropbox/dropbox-sdk-java (not sure about that, first time I'm trying to use it... )
Then on build.gradle I added
dependencies {
// ...
compile 'com.dropbox.core:dropbox-core-sdk:3.0.8'
}When I execute the app, the authentication is working, also
DbxClientV2 client = new DbxClientV2(config, accessToken);Is working, but the app stop running after
ListFolderResult result = client.files().listFolder("");or even befor that, if I try to use
FullAccount account = client.users().getCurrentAccount();
If I use the emulator, the output on Logcat is:
09-03 21:11:39.413 18255-18255/? E/Zygote: v2
09-03 21:11:39.413 18255-18255/? I/libpersona: KNOX_SDCARD checking this for 10169
KNOX_SDCARD not a persona
09-03 21:11:39.414 18255-18255/? E/Zygote: accessInfo : 0
09-03 21:11:39.414 18255-18255/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2], Con:u:r:zygote:s0 RAM:SEPF_SECMOBILE_7.0_0010, [-1 -1 -1 -1 0 1]
09-03 21:11:39.416 18255-18255/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.example.downloadfilestry
09-03 21:11:39.425 18255-18255/? I/art: Late-enabling -Xcheck:jni
09-03 21:11:39.465 18255-18255/? D/TimaKeyStoreProvider: TimaKeyStore is not enabled: cannot add TimaSignature Service and generateKeyPair Service
09-03 21:11:39.948 18255-18255/com.example.downloadfilestry I/InstantRun: starting instant run server: is main process
09-03 21:11:40.052 18255-18255/com.example.downloadfilestry W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
09-03 21:11:40.201 18255-18255/com.example.downloadfilestry D/TextView: setTypeface with style : 0
09-03 21:11:40.202 18255-18255/com.example.downloadfilestry D/TextView: setTypeface with style : 0
09-03 21:11:40.212 18255-18255/com.example.downloadfilestry D/TextView: setTypeface with style : 0
09-03 21:11:40.215 18255-18255/com.example.downloadfilestry D/TextView: setTypeface with style : 0
09-03 21:11:40.432 18255-18255/com.example.downloadfilestry D/NetworkSecurityConfig: No Network Security Config specified, using platform default
09-03 21:11:40.459 18255-18255/com.example.downloadfilestry I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-03 21:11:40.460 18255-18255/com.example.downloadfilestry I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-03 21:11:40.461 18255-18255/com.example.downloadfilestry D/AndroidRuntime: Shutting down VM
09-03 21:11:40.463 18255-18255/com.example.downloadfilestry E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.downloadfilestry, PID: 18255
java.lang.RuntimeException: Unable to resume activity {com.example.downloadfilestry/com.example.downloadfilestry.MainActivity}: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3844)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3885)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3051)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)
at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
at java.net.InetAddress.getAllByName(InetAddress.java:752)
at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:209)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:163)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:105)
at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:489)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:465)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:371)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:503)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:130)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:261)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
at com.dropbox.core.http.StandardHttpRequestor.getOutputStream(StandardHttpRequestor.java:123)
at com.dropbox.core.http.StandardHttpRequestor.access$000(StandardHttpRequestor.java:28)
at com.dropbox.core.http.StandardHttpRequestor$Uploader.<init>(StandardHttpRequestor.java:133)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:72)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:28)
at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:256)
at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:121)
at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:300)
at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:116)
at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:1612)
at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:1662)
at com.example.downloadfilestry.MainActivity.onResume(MainActivity.java:67)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1277)
at android.app.Activity.performResume(Activity.java:7121)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3821)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3885)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3051)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
If I use my phone, the output on Logcat is:
09-03 21:29:23.491 31016-31016/? E/Zygote: v2
09-03 21:29:23.492 31016-31016/? I/libpersona: KNOX_SDCARD checking this for 10169
KNOX_SDCARD not a persona
09-03 21:29:23.493 31016-31016/? E/Zygote: accessInfo : 0
09-03 21:29:23.493 31016-31016/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2], Con:u:r:zygote:s0 RAM:SEPF_SECMOBILE_7.0_0010, [-1 -1 -1 -1 0 1]
09-03 21:29:23.494 31016-31016/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.example.downloadfilestry
09-03 21:29:23.498 31016-31016/? I/art: Late-enabling -Xcheck:jni
09-03 21:29:23.518 31016-31016/? D/TimaKeyStoreProvider: TimaKeyStore is not enabled: cannot add TimaSignature Service and generateKeyPair Service
09-03 21:29:23.554 31016-31016/com.example.downloadfilestry W/ActivityThread: Application com.example.downloadfilestry is waiting for the debugger on port 8100...
09-03 21:29:23.574 31016-31016/com.example.downloadfilestry I/System.out: Sending WAIT chunk
09-03 21:29:24.580 31016-31023/com.example.downloadfilestry I/art: Debugger is active
09-03 21:29:24.776 31016-31016/com.example.downloadfilestry I/System.out: Debugger has connected
waiting for debugger to settle...
09-03 21:29:24.977 31016-31016/com.example.downloadfilestry I/System.out: waiting for debugger to settle...
09-03 21:29:25.177 31016-31016/com.example.downloadfilestry I/System.out: waiting for debugger to settle...
09-03 21:29:25.378 31016-31016/com.example.downloadfilestry I/System.out: waiting for debugger to settle...
09-03 21:29:25.578 31016-31016/com.example.downloadfilestry I/System.out: waiting for debugger to settle...
09-03 21:29:25.778 31016-31016/com.example.downloadfilestry I/System.out: waiting for debugger to settle...
09-03 21:29:25.979 31016-31016/com.example.downloadfilestry I/System.out: waiting for debugger to settle...
09-03 21:29:26.179 31016-31016/com.example.downloadfilestry I/System.out: debugger has settled (1500)
09-03 21:29:26.659 31016-31016/com.example.downloadfilestry I/InstantRun: starting instant run server: is main process
09-03 21:29:26.695 31016-31023/com.example.downloadfilestry I/art: Starting a blocking GC Instrumentation
09-03 21:29:26.808 31016-31016/com.example.downloadfilestry W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
09-03 21:29:27.020 31016-31016/com.example.downloadfilestry D/TextView: setTypeface with style : 0
09-03 21:29:27.024 31016-31016/com.example.downloadfilestry D/TextView: setTypeface with style : 0
09-03 21:29:27.070 31016-31016/com.example.downloadfilestry D/TextView: setTypeface with style : 0
09-03 21:29:27.083 31016-31016/com.example.downloadfilestry D/TextView: setTypeface with style : 0
09-03 21:29:37.114 31016-31021/com.example.downloadfilestry I/art: Do partial code cache collection, code=31KB, data=27KB
After code cache collection, code=30KB, data=27KB
Increasing code cache capacity to 128KB
09-03 21:29:39.360 31016-31016/com.example.downloadfilestry D/NetworkSecurityConfig: No Network Security Config specified, using platform default
09-03 21:29:41.825 31016-31016/com.example.downloadfilestry I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-03 21:29:41.832 31016-31016/com.example.downloadfilestry I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
09-03 21:29:42.114 31016-31021/com.example.downloadfilestry I/art: Do partial code cache collection, code=62KB, data=61KB
After code cache collection, code=60KB, data=60KB
09-03 21:29:42.115 31016-31021/com.example.downloadfilestry I/art: Increasing code cache capacity to 256KB
09-03 21:29:45.442 31016-31016/com.example.downloadfilestry D/AndroidRuntime: Shutting down VM
09-03 21:29:45.474 31016-31016/com.example.downloadfilestry E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.downloadfilestry, PID: 31016
java.lang.RuntimeException: Unable to resume activity {com.example.downloadfilestry/com.example.downloadfilestry.MainActivity}: android.os.NetworkOnMainThreadException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3844)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3885)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3051)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)
at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
at java.net.InetAddress.getAllByName(InetAddress.java:752)
at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:209)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:163)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:105)
at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:489)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:465)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:371)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:503)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:130)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:261)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
at com.dropbox.core.http.StandardHttpRequestor.getOutputStream(StandardHttpRequestor.java:123)
at com.dropbox.core.http.StandardHttpRequestor.access$000(StandardHttpRequestor.java:28)
at com.dropbox.core.http.StandardHttpRequestor$Uploader.<init>(StandardHttpRequestor.java:133)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:72)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:28)
at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:256)
at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:121)
at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:300)
at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:116)
at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:1612)
at com.dropbox.core.v2.files.DbxUserFilesRequests.listFolder(DbxUserFilesRequests.java:1662)
at com.example.downloadfilestry.MainActivity.onResume(MainActivity.java:67)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1277)
at android.app.Activity.performResume(Activity.java:7121)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3821)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3885)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3051)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1496)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1386)
what seems to be the problem now? maybe I didn't install the SDK correctly?
Is this the way you ment to install the SDK or I missedunderstood you?
- Greg-DB8 years ago
Dropbox Community Moderator
From the error output you shared, I see that you're getting a NetworkOnMainThreadException. You can find an answer about this here:
- AppDev8 years agoExplorer | Level 3
I'm getting access denied, can you share the link again please?
- Greg-DB8 years ago
Dropbox Community Moderator
Apologies, here's the corrected link: https://www.dropboxforum.com/t5/API-Support-Feedback/NetworkOnMainThreadException-connecting-to-Dropbox-account/m-p/195874/highlight/true#M17988
About 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!