Saesun Kim
Saesun Kim

Reputation: 223

Flutter Error: Execution failed for task ':app:compileFlutterBuildDebug

I reinstall my flutter and trying to load my app again, but I am having trouble loading it up. I have tried for three days, even reinstalling my window and all program again, but I did not have any luck. Anyone can help me with this, please?

you can access my files on https://github.com/bagmk/StartUp_Project/tree/master/fluttershare-master

main.dart

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:fluttershare/pages/home.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Barter',
      debugShowCheckedModeBanner: false,
      theme:
          ThemeData(primarySwatch: Colors.deepPurple, accentColor: Colors.teal),
      home: Home(),
    );
  }
}

pubspec.yaml

name: fluttershare
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cloud_firestore: 1.0.5
  firebase_core : 1.0.3
  image_picker: 0.7.4
  firebase_storage: 8.0.3
  firebase_auth: 1.0.3
  google_sign_in: 5.0.2
  geolocator: 5.0.1
  uuid: 3.0.4
  image: 3.0.2
  animator: 0.1.4
  cupertino_icons: 1.0.2
  path_provider: 2.0.1
  firebase_messaging: 9.1.1
  timeago: 3.0.2
  cached_network_image: 
  flutter_svg:

dev_dependencies:
  flutter_test:
    sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:
  uses-material-design: true
  fonts:
    - family: Signatra
      fonts:
        - asset: assets/fonts/Signatra.ttf
  assets:
    - assets/images/google_signin_button.png
    - assets/images/upload.svg
    - assets/images/search.svg
    - assets/images/activity_feed.svg
    - assets/images/no_content.svg

gradle-wrapper.properties

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-all.zip

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.")
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {

    compileSdkVersion 29

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.test.fluttershare"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.2.2"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }

    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 {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
    implementation platform('com.google.firebase:firebase-bom:27.0.0')
    
    implementation 'com.google.firebase:firebase-analytics-ktx'
    implementation 'com.google.firebase:firebase-core:16.0.1'

}
apply plugin: 'com.google.gms.google-services'

Debug console

FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* 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.

Error log

[        ] [  +15 ms] Done persisting file store
[        ] [   +2 ms] Target kernel_snapshot failed: Exception
[        ]            #0      KernelSnapshot.build (package:flutter_tools/src/build_system/targets/common.dart:291:7)
[        ]            <asynchronous suspension>
[        ]            #1      _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:828:9)
[        ]            <asynchronous suspension>
[        ]            #2      Future.wait.<anonymous closure> (dart:async/future.dart)
[        ]            <asynchronous suspension>
[        ]            #3      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:766:32)
[        ]            <asynchronous suspension>
[        ]            #4      Future.wait.<anonymous closure> (dart:async/future.dart)
[        ]            <asynchronous suspension>
[        ]            #5      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:766:32)
[        ]            <asynchronous suspension>
[        ]            #6      Future.wait.<anonymous closure> (dart:async/future.dart)
[        ]            <asynchronous suspension>
[        ]            #7      _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:766:32)
[        ]            <asynchronous suspension>
[        ]            #8      FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:595:16)
[        ]            <asynchronous suspension>
[        ]            #9      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:318:32)
[        ]            <asynchronous suspension>
[        ]            #10     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
[        ]            <asynchronous suspension>
[        ]            #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #12     CommandRunner.runCommand (package:args/command_runner.dart:196:13)
[        ]            <asynchronous suspension>
[        ]            #13     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
[        ]            <asynchronous suspension>
[        ]            #14     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #15     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
[        ]            <asynchronous suspension>
[        ]            #16     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
[        ]            <asynchronous suspension>
[        ]            #17     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #18     main (package:flutter_tools/executable.dart:91:3)
[        ]            <asynchronous suspension>
[        ] [   +4 ms] 
[        ]            #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
[        ]            #1      AssembleCommand.runCommand (package:flutter_tools/src/commands/assemble.dart:335:7)
[        ]            <asynchronous suspension>
[        ]            #2      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
[        ]            <asynchronous suspension>
[        ]            #3      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #4      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
[        ]            <asynchronous suspension>
[        ]            #5      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
[        ]            <asynchronous suspension>
[        ]            #6      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #7      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
[        ]            <asynchronous suspension>
[        ]            #8      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
[        ]            <asynchronous suspension>
[        ]            #9      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
[        ]            <asynchronous suspension>
[        ]            #10     main (package:flutter_tools/executable.dart:91:3)
[        ]            <asynchronous suspension>
[        ] [  +10 ms] "flutter assemble" took 12,491ms.
[  +62 ms] [  +83 ms] ensureAnalyticsSent: 82ms
[        ] [   +1 ms] Running shutdown hooks
[        ] [        ] Shutdown hooks complete
[        ] [        ] exiting with code 1
[        ] > Task :app:compileFlutterBuildRelease FAILED
[        ] Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
[        ] Use '--warning-mode all' to show the individual deprecation warnings.
[        ] See https://docs.gradle.org/6.1.1/userguide/command_line_interface.html#sec:command_line_warnings
[        ] 1 actionable task: 1 executed
[        ] FAILURE: Build failed with an exception.
[        ] * Where:
[        ] Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
[        ] * What went wrong:
[        ] Execution failed for task ':app:compileFlutterBuildRelease'.
[        ] > Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
[        ] * 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 16s
[ +579 ms] Running Gradle task 'assembleRelease'... (completed in 17.0s)
[   +4 ms] "flutter apk" took 17,574ms.
[   +4 ms] Gradle task assembleRelease failed with exit code 1
[   +1 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      AndroidGradleBuilder.buildGradleApp (package:flutter_tools/src/android/gradle.dart:464:9)
           <asynchronous suspension>
           #2      AndroidGradleBuilder.buildApk (package:flutter_tools/src/android/gradle.dart:231:5)
           <asynchronous suspension>
           #3      BuildApkCommand.runCommand (package:flutter_tools/src/commands/build_apk.dart:105:5)
           <asynchronous suspension>
           #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1043:27)
           <asynchronous suspension>
           #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #6      CommandRunner.runCommand (package:args/command_runner.dart:196:13)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:284:9)
           <asynchronous suspension>
           #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:232:5)
           <asynchronous suspension>
           #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #12     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>


[ +103 ms] ensureAnalyticsSent: 98ms
[   +1 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1

flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.0, on Microsoft Windows [Version 10.0.19042.631], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio
[√] VS Code (version 1.56.2)
[√] Connected device (3 available)

• No issues found!

Upvotes: 3

Views: 21743

Answers (5)

Atlas59
Atlas59

Reputation: 11

I solved my issue by

first, delete android folder

then, run commmand flutter create . to recreate the android folder again

then, just modify some of the changes or just follow the git changes

Note: this solution is should be follow if flutter clean does not help

Upvotes: 1

Muhammad Arbaz Zafar
Muhammad Arbaz Zafar

Reputation: 661

  1. First delete your build folder
  2. Clean Flutter by using flutter clean
  3. Then click on pub get in your pubspec.yaml file
  4. Build again your project

Upvotes: 7

Ezenagu Emmanuel
Ezenagu Emmanuel

Reputation: 21

I had the same issue you are facing. What I did is this. First, I ran the code in verbose mode, I ran my application again to see the error. I noticed that in my ./android/app/ there was a build directory that shouldn't be there. This directory created a new looping instance of a file. This was the error stoping my code from working. So I deleted the ./android/app/build folder and the .gradle folder in ./android/ directory. Then ran flutter run. This solved my issue.

Basically, you want to run a more detailed report so you can see where the error is coming from then solve it. But most times deleting the build and re-running your application should do the trick.

Upvotes: 1

Max
Max

Reputation: 862

Flutter 2.2 enables the sound null safety feature by default. In my case, I have project migrated to null-safety support, but some project dependencies haven't been migrated. So, I have to specify the --no-sound-null-safety argument to make the app run and build (as one of the working solutions).

If you have the same, probably, it will help and to you:

flutter build apk --no-sound-null-safety

PS: I specified --no-sound-null-safety as run arguments in my IDE but forgot to specify it on flutter build call in the console. Idk why but flutter build doesn't tell clearly that problem was because of that missing argument.

Upvotes: -1

Saesun Kim
Saesun Kim

Reputation: 223

I followed this website

https://www.programmersought.com/article/68154823442/

It was the from the prior error, so I have fixed that, and it solved the problem.

Upvotes: 2

Related Questions