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

Flutter报错<queries>元素异常及Gradle与菜单相关问题求助

Solutions to Your Flutter & Android Studio Issues

Hey there, let's work through your problems step by step—since you're new to Flutter and Android Studio, I'll keep things clear and actionable.

1. Fixing the <queries> Element Error

Even if you think your Gradle plugin is version 4.1, there are a few key checks and adjustments for your Flutter project:

  • Verify & update Gradle plugin version manually:
    Open your Flutter project's android/build.gradle file (not the one inside the app subfolder). Look for this line in the dependencies block:
    classpath 'com.android.tools.build:gradle:4.1.0'
    
    Ensure the version is at least 4.1.0 (you can use 4.1.3 or a newer compatible version if needed). Update it if lower, then sync the project.
  • Update compileSdkVersion to 30:
    The <queries> tag requires Android 11 (API level 30) support. Open android/app/build.gradle, find these lines and set them to 30:
    compileSdkVersion 30
    targetSdkVersion 30
    
  • Clear Android Studio cache:
    If the error persists after changes, go to File > Invalidate Caches... > Invalidate and Restart to clear conflicting cached build files.

2. Gradle Plugin Version: Global vs. Per-Project

Gradle plugin versions are configured per-project, not globally. Each Flutter/Android project has its own android/build.gradle file that defines which plugin version it uses.

That said, Android Studio does have a default plugin version setting for new projects (found in File > Settings > Build, Execution, Deployment > Build Tools > Gradle > Default Gradle Plugin Version). But this only affects new projects you create—existing projects rely on their own build.gradle configurations.

3. Showing the "Project Structure" Menu in Flutter Projects

Flutter projects sometimes hide the Project Structure menu from the top bar, but two reliable ways to access it exist:

  • Use the keyboard shortcut: Press Ctrl+Alt+Shift+S (Windows/Linux) or Cmd+Alt+Shift+S (Mac)—this shortcut works for all project types in Android Studio, including Flutter.
  • Right-click the android folder: In the Project view, right-click the android folder inside your Flutter project, then select Open Module Settings—this opens the Project Structure window directly.

You can also check if the menu option is visible under File > Project Structure, but the shortcut or right-click method is more consistent for Flutter projects.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 20:52:36