dropbox/dropbox-sdk-java

Dropbox login crash on Android 13 with targetSdk 33

DynamicG-Android opened this issue · 12 comments

Hi,
I've lifted my app to targetSdk 33. The Dropbox login flow crashes on my Android 13 device when pressing "Allow" in the "grant access" dialog in the Dropbox app (i.e. throwing ActivityNotFound when trying to call back to my app). Very likely root cause: "Intent filters block non-matching intents" change introduced with Android 13 SDK 33. It works fine when reverting my app to targetSdk 31.

Are you aware of this issue? I assume this needs a patch on your side (?)

Stack trace:

Process: [com.dropbox.android](http://com.dropbox.android/)
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.myapp.MyActivity/com.dropbox.core.android.AuthActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2158)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1805)
        at android.app.Activity.startActivityForResult(Activity.java:5470)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:2)
        at android.app.Activity.startActivityForResult(Activity.java:5428)
        at androidx.activity.ComponentActivity.startActivityForResult(ComponentActivity.java:1)
        at android.app.Activity.startActivity(Activity.java:5926)
        at android.app.Activity.startActivity(Activity.java:5893)
        at dbxyzptlk.Wd.a.b(RealSafeIntentStarter.java:3)
        at com.dropbox.android.dauth.DelegatedAuthActivity$j$c.a(DelegatedAuthActivity.java:9)
        at com.dropbox.android.dauth.DelegatedAuthActivity$j.a(DelegatedAuthActivity.java:2)
        at dbxyzptlk.Vg.c.onPostExecute(DbxAsyncTask.java:10)
        at android.os.AsyncTask.finish(AsyncTask.java:771)
        at android.os.AsyncTask.-$$Nest$mfinish(Unknown Source:0)
        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:788)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7898)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Thanks for the report! We'll look into it.

Hey @DynamicG-Android, could you show me what your manifest looks like?

Are you using the com.dropbox.core.android.AuthActivity like the example app?

I got it working on the example app by adding the following intent filter under the AuthActivity

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

Let me know if that helps.

perfect. yes this works. many thanks. (and yes, my manifest entry is like in the example app).

recap for those stumbling over the same problem and seeing this - the second intent-filter needs to be added to manifest when targeting Android 13:

        <activity
            android:name="com.dropbox.core.android.AuthActivity"
            android:exported="true"
            android:configChanges="orientation|keyboard"
            android:launchMode="singleTask">
            <intent-filter>
                <!-- Change this to be db- followed by your app key -->
                <data android:scheme="db-${dropboxKey}" />
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <!-- for Android 13 -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

@DynamicG-Android We're exploring other options to not require that extra intent-filter but those will depend on an update to the Dropbox App which might take some time

Fixed. We've shipped some changes in our Dropbox application and the extra intent filter is no longer required. Feel free to remove it from your manifest.

I just tested this flow with no extra intent filter on Dropbox 298.2.2 and our example app that's being released with 5.4.2 shortly

@devPalacio thank you for fixing this. I assume it is save to leave the intent filter for users which haven't upgraded their dropbox app yet, right?

Yes, this is a valid as a workaround until you're confident your users are running a newer version of Dropbox.

FYI: This version @devPalacio mentions v298.2.2 with the fix is available to all users starting September 20, 2022.

We made a mistake when testing our sdk integration with the Dropbox app. Unfortunately the crash still exists with the latest version Dropbox. Please continue to use the extra intent filter until we come up with a better solution.

We've determined a fix from the Dropbox app side for this issue. We needed to explicitly add in the data field to the Intent and add the android.intent.category.BROWSABLE starting with this change in Android 13.

I'm going to re-open this issue until the fix in the Dropbox application is widely available.

WORKAROUND: This issue can be avoided using the answer above #406 (comment)

This PR updates the Sample app with this workaround when targeting SDK 33. https://github.com/dropbox/dropbox-sdk-java/pull/472/files

The fix should be fully released now. Please let us know if you're still seeing any issues with the latest SDK/app.