Solutions to Flutter error: Gradle task assembleDebug failed with exit code 1

  1. Due to androidX
  • in root/android/gradle/wrapper/gradle-wrapper.properties set distributionUrl=https\://services.gradle.org/distributions/gradle-7.10.0-all.zip
  • in root/android/build.gradle, set
    dependencies { classpath 'com.android.tools.build:gradle:4.3.1' }
  • check if in root/android/app/build.gradle SDK version is set to minimum 30 for:
    compileSdkVersion 30and targetSdkVersion 30
  • delete .gradle and .m2 folders from $HOME directory, as well with in app folders: root/android/.gradle and root/build
  • flutter doctor
  • flutter clean
  • flutter packages pub cache clean
  • if you changed (as me) app icon then run:
    flutter packages pub run flutter_launcher_icons:main
    it will render icons for app - without it print same error with gradle..
  • Invalidate caches in Android Studio "File" > "Invalidate Caches / Restart..."
  • try flutter doctor -v but all environment is OK
  • set android.useAndroidX and android.enableJetifier to true
  • change android device: real phone xiaomi9 / emulator Nexus 5/ emulator Pixel 2
  • flutter clean
  • change minSdkVersion from 16 to 21
  • delete some (suspicious) dart code
  • reboot my Mac

--

--

--

Lead Android Developer, Flutter Lover

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nabil Mosharraf Hossain

Nabil Mosharraf Hossain

Lead Android Developer, Flutter Lover

More from Medium

Dart для Android разработчиков // Dart for Android Developers

Flutter environment

Data pass between Flutter and Android using the Method channel

My Flutter Islamic Calendar App