Flutter报错<queries>元素异常及Gradle与菜单相关问题求助
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'sandroid/build.gradlefile (not the one inside theappsubfolder). Look for this line in thedependenciesblock:
Ensure the version is at leastclasspath 'com.android.tools.build:gradle:4.1.0'4.1.0(you can use4.1.3or 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. Openandroid/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 toFile > Invalidate Caches... > Invalidate and Restartto 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) orCmd+Alt+Shift+S(Mac)—this shortcut works for all project types in Android Studio, including Flutter. - Right-click the
androidfolder: In the Project view, right-click theandroidfolder inside your Flutter project, then selectOpen 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

