简体   繁体   中英

Importing old Eclipse Project into Android Studio gives Gradle 3.3.1 error

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.

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
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM