flutter 应用程序清单中的Set 'android:enableOnBackInvokedCallback=“true”'中的应用程序未启用OnBackInvokedCallback警告

wf82jlnq  于 2023-06-24  发布在  Flutter
关注(0)|答案(1)|浏览(374)

我正在设计一个Flutter论坛应用程序,当我试图发布消息时,在VSCode上的调试控制台中收到以下错误。

W/OnBackInvokedCallback(24004): OnBackInvokedCallback is not enabled for the application.
W/OnBackInvokedCallback(24004): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.

但是在AndroidManifest.xml文件中,我找不到'android:enableOnBackInvokedCallback'。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.kopimate">
   <application
        android:label="kopimate"
        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>
                <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>
</manifest>

最后,帖子没有显示在页面上,但是在我的项目Firebase数据库中,它显示帖子已经发布。

00jrzges

00jrzges1#

你需要自己添加。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.kopimate">
   <application
        android:label="kopimate"
        android:name="${applicationName}"
        android:enableOnBackInvokedCallback="true"
        android:icon="@mipmap/ic_launcher">

Similar Question

相关问题