geek man
geek man

Reputation: 309

Could not resolve com.android.tools.build:gradle:3.2.1. flutter

I am getting this error when I want to run my flutter app. I am using flutter 1.0.0 version and android studio 3.2.1 version.

My emulator is Pixel 2 android 8.1.

I have also used android 9 but it did not work either.

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "E:\TUT\flutter\project\myfirstapp\android\gradlew.bat" exited abnormally:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:3.2.1.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:3.2.1.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
               > jcenter.bintray.com
      > Could not resolve com.android.tools.build:gradle:3.2.1.
         > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
            > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
               > dl.google.com

* 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 27s
  Command: E:\TUT\flutter\project\myfirstapp\android\gradlew.bat app:properties

Finished with error: Please review your Gradle project setup in the android/ folder.

Upvotes: 3

Views: 4442

Answers (4)

Manny
Manny

Reputation: 46

If the project Gradle version didn't install on your machine, flutter try to download the appropriate version from google server before compile.

So

  1. Ensure your computer is connected to the Internet.
  2. Google restricted access to some of its services in certain countries, such as Iran, Cuba, Sudan, Syria and etc. Therefore, Make sure your system has access to google developer subdomains. (use VPN in restricted countries)
  3. Or Change the project Gradel version on "android\build.gradle -> dependencies" with the installed version number

Upvotes: 1

Ombori
Ombori

Reputation: 73

I was getting the same error until I ran it with internet connection,seemingly it downloaded necessary resources.

Upvotes: 3

ElhamKeshavarz
ElhamKeshavarz

Reputation: 461

enter image description here

As shown in the picture above, you should check the plugin version and required gradle version.

For checking plugin version :android-->build.gardle-->build scripts-->dependencies-->calsspath
For cheking required gardle version :android-->gradle-->wrappper-->gradle-wrapper.properties

Upvotes: 1

Martin Zeitler
Martin Zeitler

Reputation: 76789

you need to add repository google() to the buildscript dependencies of the root project.

the file might be E:\TUT\flutter\project\myfirstapp\android\build.gradle

right next to the jcenter() repository; which does not serve this dependency.

Upvotes: 3

Related Questions