You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flutter集成Dropbox上传报错:URI Scheme配置不正确

问题解决:Flutter Dropbox上传时URI Scheme配置错误

错误原因

你的AndroidManifest.xml里没有为Dropbox的AuthActivity配置指定的URI Scheme,反而把scheme加到了MainActivity的intent-filter中,还和启动Activity的MAIN/LAUNCHER动作混在一起,不符合Dropbox SDK的要求。

修正步骤

修改AndroidManifest.xml,完成以下两处调整:

  1. 添加Dropbox AuthActivity配置
    在<application>标签内、MainActivity的后面,添加专门的AuthActivity声明,并配置对应的scheme:
<activity
    android:name="com.dropbox.core.android.AuthActivity"
    android:exported="true">
    <intent-filter>
        <data android:scheme="db-o9spra3j1p1cwgk" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
    </intent-filter>
</activity>
  1. 拆分MainActivity的intent-filter
    把MainActivity里混合的intent-filter拆成两个,确保应用启动入口和Dropbox回调逻辑分开:
<activity
    android:name=".MainActivity"
    android:exported="true"
    android:launchMode="singleTop"
    android:theme="@style/LaunchTheme"
    android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
    android:hardwareAccelerated="true"
    android:windowSoftInputMode="adjustResize">
    <meta-data
        android:name="io.flutter.embedding.android.NormalTheme"
        android:resource="@style/NormalTheme" />
    <!-- 应用启动入口 -->
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>

完整修正后的AndroidManifest.xml示例

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dropbox_test">
<application
    android:label="dropbox_test"
    android:name="${applicationName}"
    android:icon="@mipmap/ic_launcher">
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize">
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <!-- Dropbox认证Activity配置 -->
    <activity
        android:name="com.dropbox.core.android.AuthActivity"
        android:exported="true">
        <intent-filter>
            <data android:scheme="db-o9spra3j1p1cwgk" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>

    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>
</manifest>

修改后重新编译运行,Dropbox的OAuth认证和文件上传功能即可正常工作。

内容的提问来源于stack exchange,提问作者Kavishka Rajapakshe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.24 13:45:52