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

AndroidManifest配置Facebook登录时遇tools:node权限关联错误

Flutter添加Facebook登录时AndroidManifest出现tools:node权限错误

我正在给包名为com.example.flutter_dami的Flutter应用集成Facebook登录功能,已经按照Facebook官方文档配置了AndroidManifest.xml的相关参数,但编译时出现错误:error : tools:node associated with an element type uses permission。

以下是我当前的AndroidManifest.xml代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.flutter_dami">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
    
        
   <application
        android:label="Daami Music"
        android:name="${applicationName}"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
        android:icon="@mipmap/launcher_icon">
        <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">
            <!-- 指定Android进程启动后立即应用到此Activity的主题。在Flutter UI初始化期间,用户会看到此主题。之后,此主题继续决定Flutter UI背后的窗口背景。 -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
              <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
              <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
              
            <activity android:name="com.facebook.FacebookActivity"
                android:configChanges=
                        "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
                android:label="@string/app_name" />
            <activity
                android:name="com.facebook.CustomTabActivity"
                >
                <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <data android:scheme="@string/fb_login_protocol_scheme" />
                </intent-filter>
            </activity>
 
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- 不要删除下面的meta-data。Flutter工具用它来生成GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

问题原因

错误的核心是在<uses-permission>标签中使用了tools:node属性,但未在<manifest>根标签声明tools命名空间,导致Android构建工具无法识别该属性。

解决方法

在<manifest>标签中添加tools命名空间声明即可,修改后的开头如下:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.flutter_dami">

修改后的完整代码

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.flutter_dami">
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="com.google.android.gms.permission.AD_ID" tools:node="remove"/>
    
        
   <application
        android:label="Daami Music"
        android:name="${applicationName}"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar"
        android:icon="@mipmap/launcher_icon">
        <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">
            <!-- 指定Android进程启动后立即应用到此Activity的主题。在Flutter UI初始化期间,用户会看到此主题。之后,此主题继续决定Flutter UI背后的窗口背景。 -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
              <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
              <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
              
            <activity android:name="com.facebook.FacebookActivity"
                android:configChanges=
                        "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
                android:label="@string/app_name" />
            <activity
                android:name="com.facebook.CustomTabActivity"
                >
                <intent-filter>
                    <action android:name="android.intent.action.VIEW" />
                    <category android:name="android.intent.category.DEFAULT" />
                    <category android:name="android.intent.category.BROWSABLE" />
                    <data android:scheme="@string/fb_login_protocol_scheme" />
                </intent-filter>
            </activity>
 
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- 不要删除下面的meta-data。Flutter工具用它来生成GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.17 03:00:04