1

After doing several searches, I'm not sure which of the handful of methods to follow to fix this.

Importing an old (3, 4 years now) Eclipse project into the latest Android Studio, using all of the defaults on import. After import, the summary says it replaced two JARs with dependencies:

android-support-v4.jar => com.android.support:support-v4:22.2.1
android-support-v7-appcompat.jar => com.android.support:appcompat-v7:22.2.1

and one library with a dependency:

google-play-services_lib => [com.google.android.gms:play-services:+]

Now, the project won't build, as it immediately gives this error:

ERROR: Could not find com.android.tools.build:gradle:3.3.1.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.1/gradle-3.3.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.3.1/gradle-3.3.1.jar

Required by:
project :

Add Google Maven repository and sync project
Open File
Enable embedded Maven repository and sync project

Seems odd that I would run into this issue out of the blue on a fresh conversion of an Eclipse project. The two URLs (jcenter.buntray.com) when hit Do give back some JSON that pretty much says resource doesn't exist.

What did I do wrong on the import? Or did I not install something in the SDK properly? Unlike the other question, AS is already telling to refer gradle to jcenter and not maven.

Ah - I left out the following - After clicking on the 'Add Google Maven' and accepting the 'preview', gradle does some processing, and reports that my gradle version is too low (minimum supported is 4.10, my version is 4.8) and gives me an option to update.

After doing an update, it seems to start building, but then returns me to the first error above, about not finding 3.3.1. (Like the project file is being reset back to import state.

Have not done any manual file saves between these steps.

Coyttl
  • 537
  • 1
  • 4
  • 19
  • Possible duplicate of [Gradle error : Could not find com.android.tools.build:gradle:2.2.3](https://stackoverflow.com/questions/41570435/gradle-error-could-not-find-com-android-tools-buildgradle2-2-3) – Zoe Mar 11 '19 at 19:20
  • and https://stackoverflow.com/questions/46316213/errorcould-not-find-com-android-tools-buildgradle3-3-issue-raise-after-upgra – Zoe Mar 11 '19 at 19:20
  • @zoe Not sure why the downvote. The first one is after someone *upgraded* gradle, the second one is saying that maven is out but reference jcenter, which AS 3.3.1 already is (ref the link in my output) – Coyttl Mar 11 '19 at 19:42
  • 1
    @Coyttl you should read the error message, in particular the "Add Google Maven repository and sync project" part of it... which should be click-able. – Martin Zeitler Mar 11 '19 at 19:53
  • @MartinZeitler Ah, I just reread my post and realized I left part of it out. My bad. Editing now. – Coyttl Mar 11 '19 at 19:56
  • 1
    @Coyttl haven't down-voted. just tried to hint for the solution, which the IDE suggests... while trying to understand the meaning of error messages often helps to understand their cause. try to clean the project once, then build with Gradle wrapper v `4.10.1`... and it's bintray, not buntray. – Martin Zeitler Mar 11 '19 at 20:06
  • @MartinZeitler (Sorry, fixed my comment - I was oddly focused on that for some reason) - Don't know if that was the issue or now, but propose this as an answer, as cleaning the project and forcing it to do a rebuild that way got rid and cleared the repeated "3.3.1" error. I'll mark it as answer! – Coyttl Mar 11 '19 at 20:12
  • 1
    @Coyttl [read the updated answers instead](https://stackoverflow.com/a/44071212/6296561) – Zoe Mar 11 '19 at 22:18

1 Answers1

3

Check the official documentation:

Could not find com.android.tools.build:gradle:3.3.1.

It happens because you have to add the google() maven repo in your buildscript block in the build.gradle file in the root folder (also called top-level file). It is required for the android gradle plugin 3.0 or higher.

buildscript {
    repositories {
        // Gradle 4.1 and higher include support for Google's Maven repo using
        // the google() method. And you need to include this repo to download
        // Android Gradle plugin 3.0.0 or higher.
        google()
        ...
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
    }
}

To update the version of gradle just edit the gradle/wrapper/gradle-wrapper.properties in the root folder.

...
distributionUrl = https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
...
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841