I am trying to import a project from Eclipse into Android Studio.
In Eclipse I exported it to gradle and then imported it into Android Studio.
Note: I am new to gradle and have no insight to problem.
Now I get this error:
> Configure project :
Running gradle version: 6.8
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'aBooks'.
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.1.1.
Searched in the following locations:
-
https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.1/gradle-7.1.1.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :
The link given leads to a “404 Page not found”.
The gradle files on my system with “gradle-7” are:
The gradle file :
buildscript {
// added crl https://tomgregory.com/anatomy-of-a-gradle-build-script/
repositories {
mavenCentral()
}
println "Running gradle version: $gradle.gradleVersion"
dependencies {
classpath 'com.android.tools.build:gradle:7.1.1' // **original error here**
// https://mvnrepository.com/artifact/com.android.tools.build/gradle
// implementation group: 'com.android.tools.build', name: 'gradle', version: '7.1.0-alpha01'
// https://mvnrepository.com/artifact/com.android.tools.build/gradle/7.1.0-alpha01
}
}
apply plugin: 'com.android.application' // 'android'
dependencies {
implementation fileTree(dir: 'libs', include: '*.jar')
implementation project(':CRLibs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
}
android {
compileSdk 26
buildToolsVersion "32.0.0"
buildFeatures {
prefab true
prefabPublishing true
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml,
...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependenciesInfo {
includeInApk true
includeInBundle true
}
// no joy
plugins { // added crl https://developer.android.com/studio/releases/gradle-plugin#groovy
id 'com.android.application' version '7.0.0-alpha13' apply false
id 'com.android.library' version '7.0.0-alpha13' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
}
I tried changing ‘7.1.1’ to ‘7.2’ no change. I have no clue on how to fix this. All the answers given in my searches do not match the versions here or were no help.
EDIT1:
Added info. when I go to file->Project Structure & Project, I see
Note that the Gradle version is blank. If I enter 6.8 or 7.1.1 and click OK, I get the same results and then if I go back the Gradle version is blank.
Gradle version 6.8 is identified at the current version(see line 2 of the error message. Don’t know if this means anything.
This is the list of my Gradel-6* files:
3
Answers
Add
google()
to yourrepositories { }
block. The Android Gradle plugin is located there.Changing the gradel version in the gradel file from
to
worked for me.
I solved this problem by passing jdk11 to gradle in
settings >Gradle >Gradle JDK