-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Description
Steps to reproduce
I face this error while try to build my project.
Expected results
i need to take build my project
Actual results
Always got error while try to build the project.
Code sample
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'dev.flutter.flutter-gradle-plugin'
}
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.shopmate_app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
### Screenshots or Video
PS D:\New folder\shopmate> flutter build apk
FAILURE: Build failed with an exception.
* Where:
* What went wrong:
Could not compile build file 'D:\New folder\shopmate\android\app\build.gradle'.
> startup failed:
build file 'D:\New folder\shopmate\android\app\build.gradle': 26: only buildscript {}, pluginManagement {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
See https://docs.gradle.org/7.5/userguide/plugins.html#sec:plugins_block for information on the plugins {} block
@ line 26, column 1.
plugins {
^
1 error
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Logs
Logs
[Paste your logs here]
Flutter Doctor output
C:\Users\admin>flutter doctor -v
[√] Flutter (Channel stable, 3.29.3, on Microsoft Windows [Version 10.0.19045.5965], locale en-IN) [697ms]
• Flutter version 3.29.3 on channel stable at D:\Development\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ea121f8 (3 months ago), 2025-04-11 19:10:07 +0000
• Engine revision cf56914
• Dart version 3.7.2
• DevTools version 2.42.3
[√] Windows Version (10 Pro 64-bit, 22H2, 2009) [2.5s]
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [3.7s]
• Android SDK at C:\Users\admin\AppData\Local\Android\Sdk
• Platform android-35, build-tools 35.0.1
• ANDROID_SDK_ROOT = C:\Users\admin\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Java\jdk-17\bin\java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: flutter config --jdk-dir="path/to/jdk"
.
• Java version Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
• All Android licenses accepted.
[√] Chrome - develop for the web [280ms]
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.13.6) [278ms]
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.13.35931.197
• Windows 10 SDK version 10.0.22621.0
[√] Android Studio (version 2024.3.2) [27ms]
• Android Studio at D:\Development\Android
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
[√] VS Code (version 1.101.2) [24ms]
• VS Code at C:\Users\admin\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.114.0
[√] Connected device (3 available) [379ms]
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.5965]
• Chrome (web) • chrome • web-javascript • Google Chrome 138.0.7204.97
• Edge (web) • edge • web-javascript • Microsoft Edge 138.0.3351.55
[√] Network resources [1,275ms]
• All expected network resources are available.
• No issues found!