I've got two workstations with Android Studio installed. The first one is having version 2.3.3, but the other one is having version 3.0. Both of them are using Gradle 3.3. The problem that I am facing is that when I create an application on the 3.0 system and then transfer it to the 2.3.3 it doesn't want to build. I am receiving
Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
I compared a build.gradle file created from the older version of Android Studio and from the newer version
3.0 version:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2.3.3:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
}
}
From the 3.0 version, I removed "google()", because it was also failing.
I am new to Android Development and I would really appreciate it if you can help me to solve my problem of using one project on both of the environments.
Could not resolve all dependencies for configuration ':classpath'. > Could not find com.android.tools.build:gradle:3.0.0. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
It happens because you are using the wrong repository.
If you want to use android plugin for gradle 3.x you have to use:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
It requires also gradle v4.+ using in gradle/wrapper/gradle-wrapper.properties :
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-all.zip
If you are using Android Studio 2.x you have to change the repository google() with maven { url "https://maven.google.com" }
If you want to use the android plugin for gradle 2.3.x you can use:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
and you can use gradle v.3.3 with:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Of course in this case you can't use the new DSL introduced with gradle v.4.x and the plugin 3.x for example the implementation() and api() DSL.
Android plugin 3.0 located in Google Maven Repository (google() line) and it requires new Gradle. You should update Gradle to version 4.1.
Open file gradle/wrapper/gradle-wrapper.properties and set
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
If you are using android studio <3.0 then go to gradle-wrapper.properties and change the gradle from 4.1 to 3.3.
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Go to top level gradle and change the gradle version from 3.0.0 to 2.3.3 and then it should work fine.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
If you are using android studio >3.0 then Go to gradle-wrapper.properties and change the gradle to 4.1.
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Go to top level gradle and change the gradle version from 3.0.0 and then it should work fine.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Related
I just migrated gradle from 3.0.1 to 4.4. Now Android Studio showing gradle build failed showing below errors.
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.android.tools.build:gradle:4.4.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/4.4/gradle-4.4.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/4.4/gradle-4.4.jar https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.4/gradle-4.4.pom https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.4/gradle-4.4.jar
Project level build.gradle file is following below
buildscript {
repositories {
jcenter()
google()
}
dependencies {
//classpath 'com.android.tools.build:gradle:3.0.1'
//replaced by 4.4 below
classpath 'com.android.tools.build:gradle:4.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
mavenCentral()
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Project structure is shown below.
You mixed up with plugin version and distributionUrl. Plugin version should be classpath 'com.android.tools.build:gradle:3.0.1' or com.android.tools.build:gradle:3.1.0. Read Android Plugin for Gradle Release Notes.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
And distributionUrl to GradleWrapper.
distributionUrl = https\://services.gradle.org/distributions/gradle-4.4-all.zip
Currently latest Version 3 gradle plugin available on android for which you have to use classpath 'com.android.tools.build:gradle:3.1.0'.
To be up to date see Configure Your Build.
Guess you mixed up Gradle and Android Gradle Plugin regarding their versions?
The latest Android Gradle Plugin is v4.0.0 as of April 2020, which maps to Gradle v6.1.1.
I am trying to upgrade the version of Firebase to 11.4.2
I made the following changes in my project:
in project gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and my module gradle file:
compile "com.google.firebase:firebase-messaging:11.4.2"
I am getting this error when I build the project:
Error:Could not GET
'https://maven.google.com/com/google/firebase/firebase-messaging/11.4.2/firebase-messaging-11.4.2.pom'.
Received status code 403 from server: Authentication required
To fix the problem:
Download Android Studio 3.0 version
Update the Gradle plugin to classpath 'com.android.tools.build:gradle:3.0.0'
Update gradle wrapper version of the project to: distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip
The build tools must be at least 26.0.2
if you are working with proxy, you must configure your project gradle.
With new Android Studio 3.0 the error list suggests a "link" "Add Google Maven repository and sync project", which will change build.grade (Module:...) repositories to:
repositories {
mavenLocal()
flatDir {
dirs 'libs'
}
**google()**
}
that fixed my problem.
I update the gradle plugin to the latest, and i'm getting this error:
Error:Could not find com.android.tools.build.gradle:3.0.0-alpha7:.
Searched in the following locations:
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
https://maven.google.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
https://maven.google.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
Here's my build.gradle
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Where i'm getting wrong? since i modified my gradle.build according to the question Could not find com.android.tools.build:gradle:3.0.0-alpha1 in circle ci
thank you!!
-- Updated the build.gradle according to Mr Tim, but i'm still having the same error
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Follow the steps in the 3.0.0 plugin migration guide
Update gradle version
The new Android plugin requires Gradle version 4.1-milestone-1 or
higher. If you're opening an existing project using Android Studio 3.0
Preview 5 or later, follow the prompts to automatically update an
existing project to the compatible version of Gradle.
To update Gradle manually, update the URL in gradle-wrapper.properties
as follows:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
and
Apply the plugin
If you're opening an existing project using Android
Studio 3.0 Preview 5 or later, follow the prompts to automatically
update your project to the latest version of the Android plugin. To
manually update your project, include the maven repo and change the
plugin version in your project-level build.gradle file as follows:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' //Minimum supported Gradle version is 4.6
}
}
You try :
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
Credits: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
If you're in Android Studio 3.1 or higher, you're likely encounter such type of issue prompting by a Build window.
Simply click on the Add Google Maven repository and sync project option at right side and initiate another gradle sync.
It'll make the necessary changes in both gradle-wrapper.properties as well as build.gradle files.
Update gradle plugin : in gradle.properties file
add this line
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
then apply ther plugin in build.gradle file :
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
the distributionUrl property inside gradle-wrapper.properties should be:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
that works for me
open the file path(just as the log said):
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/
found this file
just change classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
to classpath 'com.android.tools.build.gradle:* * * ' ; * * * is the exist gradle file;
this problem is because of gradle file do not found
I installed the Kotlin plugin into my app (v. v1.1.1-release-Studio2.2-1) and then selected "Configure Kotlin in Project" I selected compiler and runtime version of 1.0.7. Kotlin updated my Gradle files. Now when I try to build in I get:
Error: A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7.
Required by:
MyApplication:app:unspecified
I'm not sure what I'm missing here.
replace
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
^
|
JRE = Java Runtime Environment
with
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
^
|
JDK = Java Development Kit
Since the version with jre is absolute , just replace and sync the project
Official Documentation here Thanks for the link # ROMANARMY
In Project level build.gradle use only this version
ext.kotlin_version = '1.3.31'
Remove other versions
This will only work with the latest version of android studio 3.4
UPDATE: Try to use the latest version of kotlin with latest Android studio to avoid an error.
The split of kotlin-stdlib into kotlin-stdlib-jre7 and kotlin-stdlib-jre8 was only introduced with Kotlin 1.1, that's why the dependency cannot be resolved, the package version simply does not exist.
It looks like the update to your project files failed at some point and set the Kotlin version to 1.0.7. If this is a new project and there's nothing holding you back from using 1.1.1, I'd switch to that. Your problem should be gone after doing this.
If you hereafter removing Jcenter from Gradle then add this to your gradle
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
So main point is that, add mavenCentral() and maven { url "https://jitpack.io" } in gradle
In "build.gradle" file, change current Kotlin version that line and press synk:
ext.kotlin_version = '1.1.1'
/// That will look like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.1'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
A new solution if you use Android Studio 3.2, I solved this issue by added mavenCentral() to build.gradle of the project:
buildscript {
ext.kotlin_version = '1.3.0'
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
You should add the line as this order, the credited is for this answer
Starting with Kotlin 1.1.2, the dependencies with group org.jetbrains.kotlin are by default resolved with the version taken from the applied plugin. You can provide the version manually using the full dependency notation like:
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
If you're targeting JDK 7 or JDK 8, you can use extended versions of the Kotlin standard library which contain additional extension functions for APIs added in new JDK versions. Instead of kotlin-stdlib, use one of the following dependencies:
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
buildscript {
**ext.kotlin_version = '1.1.1'** //Add this line
repositories {
**jcenter()** //Add this line
google()
}
dependencies {
// classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
**jcenter()** //Add this line
google()
maven { url "https://jitpack.io" }
}
}
I have solved this issue using deselection of the Offline work option in Settings
This is what worked for me:
Using Gradle 4.8.1
buildscript {
ext.kotlin_version = '1.1.1'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'}
}
allprojects {
repositories {
mavenLocal()
jcenter()
google()
maven {
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://dl.bintray.com/kotlin/kotlin-dev/'
}
}
}
If you are using Android Studio 3.2 & above,then issue will be solved by adding google() & jcenter() to build.gradle of the project:
repositories {
google()
jcenter()
}
Please check current version of your Kotlin in below path,
C:\Program Files\Android\Android Studio\gradle\m2repository\org\jetbrains\kotlin\kotlin-stdlib\1.0.5
change to that version (1.0.5) in project level gradle file.
You can see in your above path does not mentioned any Java - jre version, so remove in your app level gradle file as below,
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
build.gradle (Project)
buildScript {
...
dependencies {
...
classpath 'com.android.tools.build:gradle:4.0.0-rc01'
}
}
gradle/wrapper/gradle-wrapper.properties
...
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Some libraries require the updated gradle. Such as:
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines"
GL
In case a (transitive) dependency still uses the jre variant of the Kotlin library, you can force the use of the jdk variant with the help of a resolution strategy:
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
details.requested.with {
if (group == "org.jetbrains.kotlin" && name.startsWith("kotlin-stdlib-jre")) {
details.useTarget(group: group, name: name.replace("jre", "jdk"), version: version)
details.because("Force use of 'kotlin-stdlib-jdk' in favor of deprecated 'kotlin-stdlib-jre'.")
}
}
}
}
}
After fixing the build.gradle version, It started working
4.0.0 to 3.5.0
Reload sdk maybe the problem is solved
Simple Steps:
Click File > Project Structure
Click Dependencies >
Find and Click org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.21 (or whatever your current version is)
Under Details > update section, click [update variable][update
dependencies]
Click Ok
In my case problem solved by adding the following lines in build.gradle file:
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" } //remember to add this line
}
}
Recently I have updated my Android Studio to latest version from Latest Android Studio Canary Build: 2.0 Preview
After updating to the new version, my current working directory stop working at all. Every single time when I am trying to clean and build a project they will give me an error like this
Blockquote
'Error:Could not find com.android.tools.build:gradle:2.0.0-alpha2.
Searched in the following locations:
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/2.0.0-alpha2/gradle-2.0.0-alpha2.pom
file:/Applications/Android Studio.app/Contents/gradle/m2repository/com/android/tools/build/gradle/2.0.0-alpha2/gradle-2.0.0-alpha2.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.0.0-alpha2/gradle-2.0.0-alpha2.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.0.0-alpha2/gradle-2.0.0-alpha2.jar
Required by:
:android 3:unspecified'
Anyone have an idea how to solve this problem. Thanks in advance.
UPDATE: I am using a Mac machine and installation directory look like
Apparently the build tools have been moved from maven to jcenter so you need to change the code from:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
}
}
to this
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha2'
}
}
More details on the changes:
Android Tools Project Site
http://tools.android.com/recent
Android Developer Tools community https://plus.google.com/communities/114791428968349268860/stream/7f20992b-7d9a-4309-9d94-6fbe08f0ad6e
In the main build.gradle file, add jcenter() as main repo, just like that :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Remove other repositories or make sure jcenter is the first one.
On my side travis build failed with error message "Could not find com.android.tools.build:gradle:3.0.1".
After addeing google() as additional repository the problem was gone.
buildscript {
repositories {
jcenter()
google()
My local build did not fail because i had installed before "com.android.tools.build:gradle:3.0.1" with anddroid-sdk-manager
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
repositories block should be in buildscript.
Check to see if gradle 2.0.0-alpha1 is available on your system. Look in your android/tools/build/gradle folder. In my case, despite the confusing message "This project is using a preview version of the Gradle plugin (2.0.0-alpha2) and a newer version is available (2.0.0-alpha2) You can update to 2.0.0-alpha2." the version in my folder was 2.0.0-alpha1, and changing my build.gradle to:
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
fixed my build problem.
I removed the newest folder gradle-4.1-all in C:\Users\YOUR_USER_NAME\ .gradle\wrapper\dists\ and then I created a new project in Android Studio and the following message disappeared:
"Gradle sync failed: Could not find com.android.tools.build: Gradle:
3.0.0-beta6. "
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried something like
platfoms > android > cordova >lib > builders > Gradlebuilder.js
Downloaded zip and given path
var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'file\:///C:/MyPC/Documents/softwares/gradle-2.14.1-all.zip';
and linking path is
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven{url "http://jcenter.bintray.com"}
}
}
It worked for me.
this is for Ionic developers *
This seems to be a very long issue(years on the making)...most of the hints are about settings and gradle scripts. After a few days of digging around and backing from BumbleBee to 3.4.2 I kept on getting the same issue no matter what I tried. In the end the gradle on line URLs are blocked for my location due to network ... so easy for Google to say check the access is proper and not keep us blindfolded throwing darts in the dark