GNassro
GNassro

Reputation: 1071

after upgrade flutter to version 3, my exist project is not building

i was working on project using flutter 2.10.0 version, it work fine, but after upgrade flutter to 3.0.0 version, my project is not building, it give me this error

[        ] > Task :app:compileFlutterBuildDebug 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.7/userguide/command_line_interface.html#sec:command_line_warnings
[        ] 1 actionable task: 1 executed
[        ] FAILURE: Build failed with an exception.
[        ] * Where:
[        ] Script '/home/user/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1156
[        ] * What went wrong:
[        ] Execution failed for task ':app:compileFlutterBuildDebug'.
[        ] > Process 'command '/home/user/snap/flutter/common/flutter/bin/flutter'' 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 18s
[ +550 ms] Exception: Gradle task assembleDebug failed with exit code 1

Upvotes: 8

Views: 9689

Answers (4)

Reza
Reza

Reputation: 110

I had this problem after upgrading Flutter to version 3.17.0 and faced an issue. It turned out the problem was with the cached_network_image package, which I updated to the newest version (^3.3.0). Problem solved!

Upvotes: 1

Dazly Gonsalves
Dazly Gonsalves

Reputation: 201

This blog post might help you out:

If you create a new project with the Flutter tool, you might notice that the generated files now use the latest versions of the Gradle and Android Gradle plugins. For existing projects, you need to manually bump the versions to 7.4 for Gradle, and 7.1.2 for the Android Gradle plugin.

Upvotes: 5

GNassro
GNassro

Reputation: 1071

I tried the solution of Kamrul Hasan Jony, but it always failed to build.

So the solution that worked for me is:

  1. Created a new flutter project with the same package name
  2. Update pubsec.yaml file with packages from old project
  3. Update all changed files like android/build.gradle, android/app/build.gradle, AndroidManifest.xml ...

Upvotes: 2

Md. Kamrul Amin
Md. Kamrul Amin

Reputation: 2415

I fixed it updating 'build.gradle' from:

classpath("com.android.tools.build:gradle:3.5.3")

to

classpath("com.android.tools.build:gradle:3.5.4")

See more info in:

https://developer.android.com/studio/releases/gradle-plugin#4-0-0

If the above does not fix the error try this:

After changing the following line: distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip in

android/gradle/wrapper/gradle-wrapper.properties

Only need to change the version number.

Ran the following command: cd android && ./gradlew clean

Upvotes: 2

Related Questions