I was trying to gradle build a plain Java Android project. It was an ADT project imported to Android Studio. To my astonishment, at one point Gradle tried to download the Kotlin compiler!
* What went wrong:
Execution failed for task ':app:lint'.
> Could not resolve all files for configuration ':app:lintClassPath'.
> Could not download kotlin-compiler.jar (com.android.tools.external.com-intellij:kotlin-compiler:26.2.0)
> Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/external/com-intellij/kotlin-compiler/26.2.0/kotlin-compiler-26.2.0.jar'.
> Read timed out
Why the heck did gradle attempt downloading a big package like the Kotlin compiler
How do I prevent that?
More generally, how do make gradle ask me before it tries to download anything or at least prevent it from downloading non-dependencies? Such things should be installed by my distro's package manager, after all!
1) Because Gradle supports linting Kotlin code, which requires parsing it, which is implemented using classes in the Kotlin compiler.
2) By not using the lint task I guess?
3) The Kotlin compiler is a dependency. Gradle requires a specific version of this dependency in a specific layout and in a specific location, and it can't use a version installed by your package manager.
change
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
to
buildscript {
repositories {
google()
maven {
url "https://maven2.google.com"
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
maven {
url "https://maven2.google.com"
}
jcenter()
}
}
Related
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.
I'm trying to follow the steps applied in this video to implement "QR Code reader with Firebase ML in real time".
While adding this line in dependencies,
implementation 'com.otaliastudios:cameraview:2.0.0-rcl'
I got the following error
ERROR: Failed to resolve: com.otaliastudios:cameraview:2.0.0-rcl
implementation 'com.otaliastudios:cameraview:2.0.0-rcl'
Is that an L on the end ... it should be 1.
Try:
implementation 'com.otaliastudios:cameraview:2.0.0-rc1'
Update your project gradle
buildscript {
repositories {
jcenter()
google()
}
}
allprojects {
repositories {
jcenter()
google()
}
}
After clean project and sync gradle again.
So, My Friend who is in University wanted me to check out his Application,
He sent me the Project File and When I tried to Run it I was greeted with an Error Message that Detailed.
Could not Find com.android.tools.build:aapt2:3.3.2-5309881.
Any Help would be Highly Appreciated (:
Required by:
project: app
AAPT2 moved to Google's Maven repository, to use AAPT2, make sure that you have a google() dependency in your build.gradle file, as shown here:
buildscript {
repositories {
google() // here
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
}
}
allprojects {
repositories {
google() // and here
jcenter()
}
See: https://developer.android.com/studio/releases/#aapt2_gmaven
I'm very new to Android studio and Gradle so please be specific with your suggestions.
I downloaded this git repository because I needed a template of an app with OCR integrated into it. The project was built in Eclipse so I used the Android Studio Import tool to convert it to an Android Studio project. After attempting to build the project and resolving the first few errors by clicking on the links inside the errors, I got the "Could not find method implementation()" error which I can't seem to resolve.
NOTE - I installed Android Studio just today so I have everything updated.
This is what my build.gradle file looks like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
implementation 'com.rmtheis:tess-two:9.0.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
You need to add this
implementation 'com.rmtheis:tess-two:9.0.0'
in build.gradle app file under dependencies instead of build.gradle project file.
build.gradle
dependencies {
//...
implementation 'com.rmtheis:tess-two:9.0.0'
//...
}
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.