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

安装Flutter Launcher URL遇<queries>元素错误,求解决(已升级Gradle)

解决Flutter Launcher URL安装时的元素错误

你的编译错误根源很明确:标签必须作为的直接子元素存在,不能嵌套在标签内部。从你提供的代码来看,你在下已经正确放置了一份,但在标签里又重复写了一份,这就触发了"unexpected element found in "的错误。

修改后的AndroidManifest.xml代码

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

<uses-permission android:name="android.permission.INTERNET"/>

    <!-- Provide required visibility configuration for API level 30 and above -->
<queries>
  <!-- If your app checks for SMS support -->
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="sms" />
  </intent>
  <!-- If your app checks for call support -->
  <intent>
    <action android:name="android.intent.action.VIEW" />
    <data android:scheme="tel" />
  </intent>
</queries>
   <application
        android:label="cozy_app"
        android:name="${applicationName}"
        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">
            <!-- 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>

额外检查项(如果修改后仍有问题)

  • 确认你的Android Gradle Plugin(AGP)版本与Gradle版本匹配:比如Gradle 7.0+对应AGP 7.0及以上版本,AGP版本过低会无法识别标签。
  • 确保项目的compileSdkVersion设置为30或更高(在android/app/build.gradle中配置)。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 08:40:28