dropbox / dropbox-sdk-java

A Java library for the Dropbox Core API.
https://www.dropbox.com/developers/documentation/java
MIT License
593 stars 450 forks source link

Cannot resolve anything in com.dropbox.core.android #481

Open schdief06 opened 1 year ago

schdief06 commented 1 year ago

I'm currentliy integrating Dropbox into my app. I started with the desktop version, which worked flawlessly.

But now on Android I'm having problem to set everything up. I wanted to use the OAuth flow using the Dropbox app to authenticate. But all the content of com.dropbox.core.android seems to be missing. So e.g. th class com.dropbox.core.android.Auth cannot be resolved. Same for the AuthActivity.

I just added the Dropbox (and kotlin as I wasn't using it before) dependency to my build.gradle and synced gradle:

    implementation 'com.dropbox.core:dropbox-core-sdk:5.4.4'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.7.20'

All the other classes are there, just the content of android isn't.

Am I missing something? There is just this library? No dedicated Android library, right? Thanks for helping!

schdief06 commented 1 year ago

For now I will be using the web authentication as I'm doing on desktop:

        DbxRequestConfig dropboxRequestConfig = new DbxRequestConfig("text-edit/0.1");
        DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET);
        dropboxAuth = new DbxWebAuth(dropboxRequestConfig, appInfo);

        DbxWebAuth.Request authRequest = DbxWebAuth.newRequestBuilder()
                .withNoRedirect()
                .withTokenAccessType(TokenAccessType.OFFLINE)
                .build();
        String authorizeUrl = dropboxAuth.authorize(authRequest);
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(authorizeUrl));
        startActivity(browserIntent);

But I'd really like to check out the authentication via dropbox app

handstandsam commented 1 year ago

It looks like your configuration is correct including what you specified for the implementation dependencies.

Do you have the Kotlin Android plugin configured for your application? That is also required, and can be added like this: https://github.com/dropbox/dropbox-sdk-java/blob/1764d7e4bce5f59ae9f4a12bd8178b0654021216/examples/android/build.gradle#L3


Can you check out our working Android example here:

https://github.com/dropbox/dropbox-sdk-java/tree/main/examples/android

I just updated the README file associated with that example here: https://github.com/dropbox/dropbox-sdk-java/blob/main/examples/android/ReadMe.md


This is the code that triggers user authentication in the Android Application: https://github.com/dropbox/dropbox-sdk-java/blob/d0bb6fe046441908fac267d34fc8e2258f2a1eb8/examples/android/src/main/java/com/dropbox/core/examples/android/internal/api/DropboxOAuthUtil.kt#L33-L67

I hope this helps!

handstandsam commented 1 year ago

@schdief06 did that solve your issue? If so, we can close this ticket.

jamesncl commented 4 months ago

If you're using version 6.0.0 or later you are probably missing the additional dropbox-android-sdk dependency from your gradle which is now required for the Android specific parts of the SDK, because they have been split out into a separate library:

implementation 'com.dropbox.core:dropbox-core-sdk:7.0.0'
implementation 'com.dropbox.core:dropbox-android-sdk:7.0.0'

See the docs on Android usage