Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hi Dropbox Team,
I am trying, using Dropbox API, to access my files in Dropbox.
I have already done it with Dropbox API v1 and now I would like to do it with v2.
For this reason, I performed as following:-
1) As suggested, I downloaded the new DropBox-SDK from here:-
https://github.com/dropbox/dropbox-sdk-java
2) I run the file:
..\DropboxApiV2\dropbox-sdk-java-master\gradlew.bat
3) I executed "Import Project" in the Android Studio, and selected the folder:
..\dropbox-sdk-java-master\examples\android
4) I added the following line in the build.gradle file in "dependencies" section:-
compile 'com.dropbox.core:dropbox-core-sdk:3.0.6'
5) But I have the following error:-
Unable to load class 'org.grangle.loading.StyledTextOutput'
Alsothe following lines are marked in red:-
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
6) I have not yet updated "YOUR_APP_KEY_HERE" in AndroidManifest.xml with my app_key. For obtaining the app_key, in Dropbox Console, when I create the app_key
which name I have to give? Maybe "UserActivity"?
I need your help!
Thank you very much, in advance.
Andre
Hi Chuck,
thanks for your reply and for yuor advice.
I have set a project with the following classes:-
. PrvDef
. DropboxActivity
. DropboxClientFactory
. FileThumbnailRequestHandler
. GetCurrentAccountTask
. PicassoClient
DropboxActivity, DropboxClientFactory, FileThumbnailRequestHandler, GetCurrentAccountTask and PicassoClient
are exactly the same of "dropbox-sdk-java-master" project classes (apart from the package declaration, of course).
PrvDef class (attached) is slightly different from UserActivity: indeed I have commented the "filesButton" and "openWithButton" commands. Since I have a problem "before" them, I tried to simplify the project.
I run it, but the result is:-
Unfortunately, PrvDef Has stopped.
Now, if I comment the three rows in "initAndLoadData" method of DropboxActivity class, this issue disappear.
Also, both "view files" and "Test Open" buttons are enabled, that is the filing is that hasToken() method to be true.
Since my code is now so similar to "dropbox-sdk-java-master" code, it seems to me that it is no more possible for me to improve it.
Please, let me know your opinion. Thanks, in advance.
-------------------------------
Since I had a build.gradle file different from "dropbox-sdk-java-master" project one, I updated mine.
But I descovered that the build.gradle file of the "dropbox-sdk-java-master" project has Gradle errors.
I tried to remove those Gradle errors, but I have not been able to do it .
I mean, I have "Failed to resolve: com.dropbox.core:dropbox-core-sdk:0-SNAPSHOT" error.
Could you please confirm me that the build.gradle file of "dropbox-sdk-java-master" project not to have got Gradle Build errors and that project to be still running in Android correctly?
Also, I noticed that the dropbox-core-sdk library is not present in "dropbox-sdk-java-master". Where may I find the right version?
Thank you, in advance.
Kind Regards,
Andre
public class PrvDef extends DropboxActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user);
Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
Button loginButton = (Button)findViewById(R.id.login_button);
loginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Auth.startOAuth2Authentication(PrvDef.this, getString(R.string.app_key));
}
});
Button filesButton = (Button)findViewById(R.id.files_button);
filesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//startActivity(FilesActivity.getIntent(PrvDef.this, ""));
}
});
Button openWithButton = (Button)findViewById(R.id.open_with);
openWithButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Intent openWithIntent = new Intent(UserActivity.this, OpenWithActivity.class);
//startActivity(openWithIntent);
}
});
}
@Override
protected void onResume() {
super.onResume();
if (hasToken()) {
findViewById(R.id.login_button).setVisibility(View.GONE);
findViewById(R.id.email_text).setVisibility(View.VISIBLE);
findViewById(R.id.name_text).setVisibility(View.VISIBLE);
findViewById(R.id.type_text).setVisibility(View.VISIBLE);
findViewById(R.id.files_button).setEnabled(true);
findViewById(R.id.open_with).setEnabled(true);
} else {
findViewById(R.id.login_button).setVisibility(View.VISIBLE);
findViewById(R.id.email_text).setVisibility(View.GONE);
findViewById(R.id.name_text).setVisibility(View.GONE);
findViewById(R.id.type_text).setVisibility(View.GONE);
findViewById(R.id.files_button).setEnabled(false);
findViewById(R.id.open_with).setEnabled(false);
}
}
@Override
protected void loadData() {
new GetCurrentAccountTask(DropboxClientFactory.getClient(), new GetCurrentAccountTask.Callback() {
@Override
public void onComplete(FullAccount result) {
((TextView) findViewById(R.id.email_text)).setText(result.getEmail());
((TextView) findViewById(R.id.name_text)).setText(result.getName().getDisplayName());
((TextView) findViewById(R.id.type_text)).setText(result.getAccountType().name());
}
@Override
public void onError(Exception e) {
Log.e(getClass().getName(), "Failed to get account details.", e);
}
}).execute();
}
}
Hello @Andre_LB,
So after doing an examination of the Android example from the Java SDK repository, I can confirm that I am able to get it running. However, I did have to make a few edits to the build.gradle file, the proguard-rules, and Android Studio itself, when running on a fully updated version of Android Studio.
Can you post a copy of your build.gradle and also please include any app exceptions from logcat when you run the Dropbox code and the application closes?
Thanks!
-Chuck
Hi Chuck,
attached my build.gradle.
Sorry, I have wrongly explaned myself: in this situation (after I have set the build.gradle as your example) I have a Gradle Sync Issue that I had got when I run your download, that is:-
Unable to load class 'org.gradle.logging.StyledTextOutput'.
I tried to remove this error, but I am not able.
You have said that "did have to make a few edits to the build.gradle file, the proguard-rules, and Android Studio itself".
I dowload again your example: the file dates seem changed, but the files seem to be the same.
That is, I have not seen any difference: what did you change?
Thanks, in advance.
Kind Regards,
Andre
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.2'
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.rram.prvdef"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
// to debug ProGuard rules
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
disable 'InvalidPackage'
abortOnError false
}
}
dependencies {
compile 'com.dropbox.core:dropbox-core-sdk:3.0.6'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
// picasso 2.5.2 doesn't have OkHttp3 support (although it exists
// on master). Must use OkHttp v2 and v3 until new picasso release
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp3:okhttp:3.5.0'
}
apply plugin: 'com.getkeepsafe.dexcount'
dexcount {
format = "list"
includeClasses = true
includeFieldCount = false
orderByMethodCount = true
}
I only changed the files and settings locally on my checked-out version of the example to get it running for me. I will be looking at getting changes made to the example but for now, I'd like to see if we can solve your issues via the same method.
So, for the first step, can you please try making the following edit to your gradle file, replace:
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.2'
with
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
And let me know if that gets you past the StyledTextOutput error.
The next error you might encounter will require a change to proguard-rules-debug.pro. Make the following change:
-include "proguard-rules.pro"
To
-include proguard-rules.pro
(remove the quotes)
Another issue you might see is if instant app support is enabled in Android Studio. I disabled it due to classes not being properly found at runtime. To do this go to:
Files | Settings | Build, Execution, Deployment | Instant Run
And disable the setting.
Please give these changes a try and see if it makes a difference.
Thanks,
-Chuck
Hi Chuch,
thank very much for your prompt reply and suggestions.
I applied all the suggested changes.
Also I updated the buildToolsVersion from "26.0.1" into "26.0.2": now I may Sync Project without errors.
But, if I run the app, I have got a few warnings and the following Gradle Build error:-
Execution failed for task 'app:transformClassesAndResoucesWithProguardForDebug'
Let me know, please. Thanks, in advance!
Kind Regards,
Andre
Can you please include details for the warnings and anything else logged about the error? Also, simple question, have you done a clean build? (Build | Clean Project)
Thanks,
-Chuck
Hi Chuck,
thanks again for your reply and effort.
There are 57 warnings as, please, you can see: I am posting the first ten and the last seven.
Let me know, please, if you need the complete warning list.
Yes, I have. But clean build is the only command performed by me (apart from Sync Project and Run App).
Do you think me to have to execute something else?
Thanks, again.
Kind Regards,
Andre
=================================
Information:Gradle tasks [:app:assembleDebug]
Warning:com.dropbox.core.DbxStandardSessionStore: can't find referenced class javax.servlet.http.HttpSession
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.URLFetchServiceFactory
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.HTTPMethod
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.HTTPHeader
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions$Builder
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.FetchOptions
Warning:com.dropbox.core.http.GoogleAppEngineRequestor: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
......................................................................................................................
Warning:com.dropbox.core.http.GoogleAppEngineRequestor$FetchServiceUploader: can't find referenced class com.google.appengine.api.urlfetch.URLFetchService
Warning:com.dropbox.core.http.GoogleAppEngineRequestor$FetchServiceUploader: can't find referenced class com.google.appengine.api.urlfetch.HTTPRequest
Warning:com.dropbox.core.http.GoogleAppEngineRequestor$FetchServiceUploader: can't find referenced class com.google.appengine.api.urlfetch.HTTPResponse
Warning:okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:there were 77 unresolved references to classes or interfaces.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'.
> Job failed, see logs for details
Information:BUILD FAILED in 15s
Information:1 error
Information:57 warnings
Information:See complete output in console
Hi Chuck,
I have a doubt.
Till now, I have always sent you the "Module: app" build.gradle file.
Attached, please, you may fing the "Project: PrvDef" one.
Is this correct? Thanks, in advance.
Kind Regards,
Andre
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Let's take a step back here. At this point, I think it's best to just get the Android example app from the Java SDK repository running. I want to make sure we're both on the same page there. PrvDef is your custom application, correct? For the moment, I think we should hold off on that.
Can you please verify that we're currently working with a cleanly checked out copy of the Android example app that has been imported into Android studio?
If not, let's start over with that and try to get it up and running.
Thanks,
-Chuck
Hi Chuck,
I downloaded the DropBox-SDK, executed "Import Project" in Android Studio and selected the folder:
..\examples\android
Since I have got the following error:-
Error:Failed to resolve: com.dropbox.core:dropbox-core-sdk:0-SNAPSHOT
I changed in the build.gradle file (Module: Android):-
compile group: 'com.dropbox.core', name: 'dropbox-core-sdk', version: '0-SNAPSHOT', changing: true
into:-
compile 'com.dropbox.core:dropbox-core-sdk:3.0.6'
Then, in my developer app console, I created the app "UserActivity" and updated the app key in AndroidManifest file and res/strings file.
Very well: now I am able to Authenticate and download a file.
Tomorrow I am going to check the differences between your example and my app (I confirm PrvDef is my custom application).
Thank you very much for your kind help and effort.
Kind Regards,
Andre
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!