Search code examples
androidfluttergradleflutter-dependencies

Flutter Android/build.gradle not launching when starting


I am trying to add flutter local notifications to my app and following the documentation. So far i managed to get everything working but this line of code

buildscript {
   ...

    dependencies {
        classpath 'com.android.tools.build:gradle:7.3.1'
        ...
    }

Adding the build gradle classpath seems to prevent from my application launching at all. I tried changing the versions of my android tools build gradle with no luck.

Also tried to change the version to 7.6.3 presuming it will work since that is my gradle version on my gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip

Solution

  • If you are using Flutter 3.19+, you need to set up AGP version in android/settings.gradle, not in android/build.gradle - you already should has it like this id "com.android.application" version "7.3.0" apply false. So in that case you just need to change this one to necessary version instead of adding classpath in build.gradle.

    But if you use older version of Flutter or error do not disappear after this changes, please provide your android/settings.gradle, android/build.gradle and android/app/build.gradle. Also please write your previous AGP (gradle plugin) from build.gradle or settings.gradle and gradle from gradle-wrapper.properties versions.