应用程序清单中的 URI 方案未正确设置错误

问题描述 投票:0回答:2

我正在尝试使用我的 flutter 移动应用程序将文件上传到 dropbox。尝试将文件上传到 drop box 时出现以下错误。我正在使用 dropbox_client 包从 dropbox 访问、上传和下载文件

E/MethodChannel#dropbox( 6383): Failed to handle method call
E/MethodChannel#dropbox( 6383): java.lang.IllegalStateException: URI scheme in your 
app's manifest is not set up correctly. You should have a 
com.dropbox.core.android.AuthActivity with the scheme: db-o9spra3j1p1cwgk
E/MethodChannel#dropbox( 6383):     at 
com.dropbox.core.android.AuthActivity.checkAppBeforeAuth(AuthActivity.java:353)
E/MethodChannel#dropbox( 6383):     at 
com.dropbox.core.android.Auth.startOAuth2Authentication(Auth.java:161)
E/MethodChannel#dropbox( 6383):     at 
com.dropbox.core.android.Auth.startOAuth2Authentication(Auth.java:147)
E/MethodChannel#dropbox( 6383):     at 
com.dropbox.core.android.Auth.startOAuth2Authentication(Auth.java:134)
E/MethodChannel#dropbox( 6383):     at 
com.dropbox.core.android.Auth.startOAuth2Authentication(Auth.java:32)
E/MethodChannel#dropbox( 6383):     at 
com.dropbox.core.android.Auth.startOAuth2Authentication(Auth.java:24)
E/MethodChannel#dropbox( 6383):     at 
com.mix1009.dropbox.DropboxPlugin.onMethodCall(DropboxPlugin.java:161)
E/MethodChannel#dropbox( 6383):     at 
E/MethodChannel#dropbox( 6383):     at 
io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#dropbox( 6383):     at 
io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io- 
flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
E/MethodChannel#dropbox( 6383):     at 
io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown 
 Source:12)
 E/MethodChannel#dropbox( 6383):    at 
 android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#dropbox( 6383):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#dropbox( 6383):     at android.os.Looper.loopOnce(Looper.java:201)
E/MethodChannel#dropbox( 6383):     at android.os.Looper.loop(Looper.java:288)
E/MethodChannel#dropbox( 6383):     at 
android.app.ActivityThread.main(ActivityThread.java:7870)
E/MethodChannel#dropbox( 6383):     at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#dropbox( 6383):     at 
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/MethodChannel#dropbox( 6383):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

E/flutter(6383):[错误:flutter/lib/ui/ui_dart_state.cc(198)]未处理的异常: PlatformException(错误,应用程序清单中的 URI 方案设置不正确。您 应该有一个 com.dropbox.core.android.AuthActivity ,其方案为:db-o9spra3j1p1cwgk, null,java.lang.IllegalStateException:应用程序清单中的 URI 方案未设置 正确。您应该有一个 com.dropbox.core.android.AuthActivity ,其方案为: db- o9spra3j1p1cwgk E/颤动(6383):在 com.dropbox.core.android.AuthActivity.checkAppBeforeAuth(AuthActivity.java:353)

下面是我的 Android 清单文件

<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">
        <!-- Specifies an Android theme to apply to this Activity as soon as
             the Android process has started. This theme is visible to the user
             while the Flutter UI initializes. After that, this theme continues
             to determine the Window background behind the Flutter UI. -->
        <meta-data
          android:name="io.flutter.embedding.android.NormalTheme"
          android:resource="@style/NormalTheme"
          />
        <intent-filter>
            <data android:scheme="db-o9spra3j1p1cwgk" />
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
    <!-- Don't delete the meta-data below.
         This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
    <meta-data
        android:name="flutterEmbedding"
        android:value="2" />
</application>
flutter dart android-manifest dropbox dropbox-api
2个回答
0
投票

您似乎没有特别为“com.dropbox.core.android.AuthActivity”注册必要的URL方案。您可以在这里找到示例:

https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/DropboxAndroid/app/src/main/AndroidManifest.xml


0
投票

您需要做的就是在这里添加一个 authActivity,因为您需要在其中添加您的 dropbox api 密钥,这个错误就会消失..

  <activity
            android:name="com.dropbox.core.android.AuthActivity"
            android:configChanges="orientation|keyboard"
            android:exported="true"
            android:launchMode="singleTask">
            <intent-filter>

                <!-- Change this to be db- followed by your app key -->
                <data android:scheme="db-yourappkey" />

                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

尝试在 mainActivity 意图下的清单中添加此代码。

您已将其添加到 mainActivity Intent 的 Intent 过滤器中,将其删除并添加上述代码。

请告诉我

© www.soinside.com 2019 - 2024. All rights reserved.