Android Studio build gradle failded - java

I have recently downloaded Android studio version 3.6.3 . When I create a new project I get these errors:
Could not resolve all artifacts for configuration 'classpath'
Could not resolve com.android.tools.build:gradle:5.6.4.
No cached version of com.android.tools.build:gradle:5.6.4. available for offline mode.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:5.6.4'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
How should I solve this?

You are confusing the gradle version and the gradle plugin version:
The gradle plugin 5.6.4 doesn't exist.
Use:
classpath 'com.android.tools.build:gradle:3.6.3'
The version of gradle is defined in the gradle/wrapper/gradle-wrapper.properties file:
distributionUrl = https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

Related

Could not determine the dependencies of task Could not create task

I want to install the gradle plugin version 7.6
but I get this Error :
Could not determine the dependencies of task ':path_provider_android:test'.
Could not create task ':path_provider_android:testProfileUnitTest'.
this and base files have different roots: E:\flutter downloader the main program\flutterdownloaderthemainprogram\build\path_provider_android and C:\Users\Gcc\Downloads\Compressed\flutter_windows_3.3.0-stable\flutter.pub-cache\hosted\pub.dartlang.org\path_provider_android-2.0.22\android.
this is the build.gradle:
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I use the java19
I try java17 and java11
I tried diffrent version of the gradle but I get the same Error
-go to the project terminal (ctrl+j in vscode) and run flutter clean
-go to the android folder and delete the .gradle folder
-run flutter pub get
-run flutter run

Could not resolve in adding HMS Huawei repos in gradle

im trying to integrate in HMS Huawei, in adding classpath im have error:
Could not resolve com.huawei.agconnect:agcp:1.6.0.300.
my build.gradle:
buildscript {
repositories {
google()
jcenter()
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.google.gms:google-services:4.3.8'
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
}
}
allprojects {
repositories {
google()
jcenter()
repositories {
maven { url 'http://dl.bintray.com/swallowsonny/ext/' }
maven { url 'https://jitpack.io' }
maven { url 'https://developer.huawei.com/repo/' }
}
}
}
my gradle ver: 6.7.1 and gradle plugin ver: 4.1.3
Try this:
Go to File -> Project Settings -> Gradle and uncheck the Gradle offline work option.
Synchronize the project again and let all the dependencies get downloaded.
I have corrected settings.gradle like this:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter()
maven {url 'https://developer.huawei.com/repo/'} // add this line
}
}

> Could not initialize class com.android.repository.api.RepoManager

I am new in Android Studio. After setup, When I am trying to import an application I am getting that error So that gradle not able to build.
Error:> Could not initialize class com.android.repository.api.RepoManager
I checked that my classpath setting for Java is fine. I am running Windows OS. Does anyone know the source of the error?
I had this issue while trying to run a 5-year-old android project. Following these steps fixed the issue for me:
1- update gradle version in the project level build.gradle file from
classpath 'com.android.tools.build:gradle:2.2.2'
to
classpath 'com.android.tools.build:gradle:7.1.1'
2- add google() to the project repositories
allprojects {
repositories {
jcenter()
mavenLocal()
google()
}}
and in buildScript block as well:
buildscript {
repositories {
jcenter()
mavenLocal()
google()
} dependencies {...}}
3- update gradle version in gradle-wrapper.properties file to an up-to-date version, I updated to 7.2
4- In the app level build.gradle file, in the dependencies block, I changed compile to implementation
5- sync the project
A downgrade to Android Studio 4.0 fixed the error for me.

Gradle plugin supports only Kotlin Gradle plugin version 1.3.40 and higher Error when upgrading android studio gradle from 4.2.2 to 7.0.0

I have recently upgraded my Gradle version from 4.2.2. to 7.0.0. Android Studio was running the applications fine and well until i upgraded and got the below error
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.40 and higher.
The following dependencies do not satisfy the required version:
root project 'MyNewApp' -> androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha03 -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20
Below is my project level grale
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
//classpath 'com.android.tools.build:gradle:4.2.2'
def nav_version = "2.3.0-alpha03"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.google.gms:google-services:4.3.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried adding ext.kotlin_version = "1.5.0" below buildscript but its the same same error what might be the issue
I changed my navigation version to below version and it has worked
def nav_version = "2.3.5"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"

Gradle build failed to resolve library

I am working on android (Java) and trying to consume websockets so I thought I would use this tutorial and they are using dependency org.java-websocket:Java-WebSocket:1.3.0 from this repo which has now become 1.3.1.
So I have in my modular build.gradle
dependencies {
...
compile 'org.java-websocket:Java-WebSocket:1.3.1'
...
}
and in my project / top level build.gradle I have
repositories {
jcenter()
maven { url 'http://clojars.org/repo' }
}
and I am getting error
Error:(49, 13) Failed to resolve: org.java-websocket:Java-WebSocket:1.3.1
Try it with lowercase:
compile 'org.java-websocket:java-websocket:1.3.1'
It worked for me.
Edit:
the project level gradle file:
buildscript {
repositories {
jcenter()
maven { url 'http://clojars.org/repo' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
maven { url 'http://clojars.org/repo' }
}
}
I was also facing same issue ,I restarted Android Studio and sync again,it build successfully.

Categories

Resources