FAILURE: Build failed with an exception. * Where: Build file 'D:\AProjects\flutter_app\android\app\build.gradle' line: 24
10,665
You mixed up where you have to add apply plugin 'com.android.application'
.
You added it in the wrong build gradle.
It should go in:
'D:\AProjects\snd_app\android\build.gradle'
.
You will most likely have another error arise after fixing this, because of a switch also. Move those from android\build.gradle
to android\app\build.gradle
.
Author by
Arish Siddiqui
Updated on December 27, 2022Comments
-
Arish Siddiqui over 1 year
Hey I am trying to compile my flutter project on my real device, but this is the error or issue I am currently facing. Does anyone have a solution for this.
FAILURE: Build failed with an exception. * Where: Build file 'D:\AProjects\flutter_app\android\app\build.gradle' line: 24 * What went wrong: A problem occurred evaluating project ':app'. > Plugin with id 'com.android.application' not found. * 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.
I am currently using latest version of flutter. And I am getting this error in my every project. This is what I have in android\app\build.gradle:
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 GradleException("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' } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { compileSdkVersion 30 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.flutter_app" minSdkVersion 16 targetSdkVersion 30 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" }
& This is what I have in android\build.gradle :
buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir }
-
Kilian about 3 yearsCan you show is your build.gradle and especially what is on line 24?
-
Sisir about 3 yearsIssue similar as described here: stackoverflow.com/questions/24795079/… ?
-
Arish Siddiqui about 3 yearsPlease have a look on it : apply plugin: 'com.android.application'. This is code what I have on 24th line.
-
-
Arish Siddiqui about 3 yearsCan you please explain this in more detail, I didn't got your point.
-
Rohan Thacker about 3 yearsstackoverflow.com/questions/25880174/… Please check the top-voted answer in the question linked above. Android projects have a projects have 2 build.gradel files. One at the root of your project and another in your app.