Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
schdief06 opened this issue Nov 29, 2022 · 4 comments
Open

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

schdief06 opened this issue Nov 29, 2022 · 4 comments

Comments

@schdief06
Copy link

schdief06 commented Nov 29, 2022

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
Copy link
Author

schdief06 commented Nov 29, 2022

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
Copy link
Contributor

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:

id 'org.jetbrains.kotlin.android'


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:

/**
* Starts the Dropbox OAuth process by launching the Dropbox official app or web
* browser if dropbox official app is not available. In browser flow, normally user needs to
* sign in.
*
* Because mobile apps need to keep Dropbox secrets in their binaries we need to use PKCE.
* Read more about this here: https://dropbox.tech/developers/pkce--what-and-why-
**/
fun startDropboxAuthorization2PKCE(context: Context) {
val requestConfig = DbxRequestConfig(dropboxAppConfig.clientIdentifier)
// The scope's your app will need from Dropbox
// Read more about Scopes here: https://developers.dropbox.com/oauth-guide#dropbox-api-permissions
val scopes = listOf(
"account_info.read",
"files.content.write",
"files.content.read",
"sharing.read"
)
Auth.startOAuth2PKCE(context, dropboxAppConfig.apiKey, requestConfig, scopes)
isAwaitingResult = true
}
/**
* Starts the Dropbox OAuth process by launching the Dropbox official app or web
* browser if dropbox official app is not available. In browser flow, normally user needs to
* sign in.
*
* Because mobile apps need to keep Dropbox secrets in their binaries we need to use PKCE.
* Read more about this here: https://dropbox.tech/developers/pkce--what-and-why-
**/
fun startDropboxAuthorizationOAuth2(context: Context) {
Auth.startOAuth2Authentication(context, dropboxAppConfig.apiKey)
isAwaitingResult = true
}

I hope this helps!

@handstandsam
Copy link
Contributor

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

@jamesncl
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants