Could not find com.android.tools.build:gradle:2.2.2 - java

A friend of mine copy pasted a libgdx project folder on his pc and sent the project to me(through google drive). We are both using Android Studio. I downloaded and imported the project and it is working properly on the emulator. However it is not working on the desktop. On his pc, it works both in desktop and in the emulator.
When I try to run it in the desktop, Android Studio gives me this error message:
Error:Gradle: A problem occurred configuring root project 'bouncerGDX - Copy'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:2.2.2.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.2/gradle-2.2.2.jar
Required by:
:bouncerGDX - Copy:unspecified
How can I fix this? I have no experience with Gradle.

UPD:
It seems can't resolve com.android.tools.build:gradle:2.2.2 dependency for the classpath.
For me, adding the jcenter to build.gradle resolves the issue:
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
}
or, alternatively, the line in build.gradle
classpath 'com.android.tools.build:gradle:2.2.2'
can be changed to
classpath 'com.android.tools.build:gradle:2.1.3'
^^^ this version exist in repo1.maven.org
WRONG SUGGESTION:
Resolve all dependencies by running gradle task (can be done from Android Studio's terminal):
For Linux:
./gradlew buildDependents
For Windows:
gradlew.bat buildDependents
Also, this commands might also help later
Linux:
./gradlew cleanIdea idea
Windows:
gradlew.bat cleanIdea idea
This is the reference to libgdx How-to-setup-development-env instruction

I was getting the same issue after updating Android Studio 2.2.2 to 2.3.1
Could not find com.android.tools.build:gradle:2.2.2.
Solution:
Open the gradle location and make changes in build.gradle accordingly(module and project both)
I replaced
classpath 'com.android.tools.build:gradle:2.2.2'
with
classpath 'com.android.tools.build:gradle:2.3.1'
And gradle build successfully :-)
gradle location

buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
add google() below jcenter(),this works for me

Seems like you hav dependency on the library project bouncerGDX
You can open build.gradle of that project and change gradle version which is available with you. e.g.
classpath 'com.android.tools.build:gradle:2.1.0'

My fix for the same error was to configure Android Studio for the proxy I'm stuck behind.
Android Studio + Gradle did not assume system proxy settings, at least not on my copy of macOS. Set your proxy settings in Preferences > Appearance & Behavior > System Settings > HTTP Proxy, save them and restart Android Studio. It then prompted me to set Gradle's proxy settings to match Android Studio's. Once I did this, no more error.

Adding the maven url solved the issue for me.
buildscript {
repositories {
mavenCentral()
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}

[Solution For Android 2.3.1 built in 2017 April]
In gradle.build(Project)
Add missing repositories
mavenLocal() and jcenter()
To
buildscript { repositories { }}
Notice there are TWO gradle.build files!! Pick the right one.

In my case I was updating Gradle as Android Studio recommended
Solution:
When you import the project make sure not to update Gradle (click "Don't remind me again for this project") and it should work.

Note: Use latest gradle version.

Related

Android Studio `Plugin with id 'com.android.application' not found` [duplicate]

This is my first attempt at Android Studio. I installed 0.8.0 and updated to 0.8.2. As soon as a project is created I get the error message:
Error:(1, 0) Plugin with id 'com.android.application' not found
C:\Users\Bob\AndroidStudioProjects\HelloAgain6\app\build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.bob.helloagain6"
minSdkVersion 15
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
and C:\Users\Bob\AndroidStudioProjects\HelloAgain6\build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Updated Answer (Dec. 2, 2020)
Latest Gradle: 6.5
Version check:
./gradlew -v
How to update:
Set URL: ./gradlew wrapper --gradle-version=6.5 --distribution-type=all
Update: ./gradlew wrapper
Latest Android Gradle Plugin: 4.1.0
If you add the following code snippet to the top of your build.gradle file. Gradle will update the build tools.
buildscript {
repositories {
google() // For Gradle 4.0+
maven { url 'https://maven.google.com' } // For Gradle < 4.0
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
Read more here: https://developer.android.com/studio/build/index.html and about version compatibility here: https://developer.android.com/studio/releases/gradle-plugin.html#updating-gradle and https://dl.google.com/dl/android/maven2/index.html.
Original Answer
I had this same error, you need to make sure your Gradle version is compatible with your Android Gradle Plugin.
The latest version of Gradle is 2.0 but you need to use 1.12 in order to use the Android Gradle Plugin.
This can happen if you miss adding the Top-level build file.
Just add build.gradle to top level.
It should look like this
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.xx.y'
}
}
allprojects {
repositories {
mavenCentral()
}
}
In my case, I download the project from GitHub and the Gradle file was missing. So I just create a new project with success build. Then copy-paste the Gradle missing file. And re-build the project is working for me.
Root-gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:x.x.x'
}
}
allprojects {
repositories {
jcenter()
}
}
Gradle-wrapper.properties file:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-x.x-all.zip
In the project level build.gradle file, I have replaced this line
classpath 'com.android.tools.build:gradle:3.6.3'
with this one
classpath 'com.google.gms:google-services:4.3.3'
After adding both of those lines, and syncing, everything became fine.
Hope this will help someone.
I am writing this not as a solution meant for many, but for some people who may commit a simple mistake like specifying the wrong url for importing projects from SVN. It is intended for those guys :)
This happened to me when I imported the project from SVN -> automatic prompt by Studio to open the project -> It asked for Gradle location -> D:\Software\Android\gradle-2.5 -> Then the error.
The same project in a different SVN branch works fine with the Gradle plugin and Gradle which I have configured in Studio. I tried changing Android Gradle plugin and Gradle to get it working on the erring branch without any success.
Finally, I figured out that it was my following mistake:
I tried importing a specific Application alone instead of importing the application along with dependent library projects.
The url which I used for import initially had the Application porject's name at the end. Once I removed it, and specified the parent directory which contained both application project and its dependent project, everything went smooth :)
I found the problem after one hour struggling with this error message:
I accidentally renamed the root build.gradle to filename in builde.gradle, so Android Studio didn't recognize it anymore.
Renaming it to build.gradle resolved the issue!
I still got the error
Could not find com.android.tools.build:gradle:3.0.0.
Problem: jcenter() did not have the required libs
Solution: add google() as repo
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:3.0.0"
}
}
I was using IntelliJ IDEA 13.1.5 and faced with the same problem after I changed versions of Picasso and Retrofit in dependencies in build.gradle file. I tried use many solutions, but without result.
Then I cloned my project from remote git (where I pushed it before changing versions of dependencies) and it worked! After that I just closed current project and imported old project from Gradle file to IntelliJ IDEA again and it worked too! So, I think it was strange bug in intersection of IDEA, Gradle and Android plugin. I hope this information can be useful for IDEA-users or anyone else.
Go to your grade file where you can see this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
And change classpath to this:
buildscript {
repositories {
jcenter()
}
dependencies {
// classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle-experimental:0.7.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
The other answers didn't work for me, I guess something wrong happens between ButterKnife and 3.0.0 alpha5.
However, I found that when I annotated any one sentence, either BUtterKnife or 3.0.0 alpha5, it works normally.
So, you should just avoid the duplication or conflict.
For future reference: For me, this issue was solely caused by the fact that I wasn't running Android Studio as administrator. I had the shortcut on Windows configured to always run as administrator, but after reinstalling Android Studio, the shortcut was replaced, and so it ran without administrator rights. This caused a lot of opaque errors, including the one in this question.
This issue happened when I accidently renamed the line
apply plugin: 'com.android.application'
on file app/build.gradle to some other name. So, I fixed it by changing it to what it was.
[FOR FLUTTER] go to your build Gradle then check if you have three paths
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
I somehow removed the android tools classpath and was getting the error.
This just happened to me using Android Studio 1.3.2, however, since I had just created the project, I deleted it and created it again.
It seems that it had not been properly created by Android Studio the first time, not even the project folders where as expected.
If you run a the module task with android plugin 1.2.3 in module directory , the problem appears. Try this:
../gradlew -b ../build.gradle -c ../settings.gradle :module:xxx
Make sure your two build.gradle and settings.gradle files are in the correct directories as stated in https://developer.android.com/studio/build/index.html
Then open "as existing project" in Visual Studio
Gradle is very finicky about this.
I got this error message after making the following change in my top-level build.gradle to update to the latest version of gradle:
//classpath 'com.android.tools.build:gradle:2.3.2' old
classpath 'com.android.tools.build:gradle:2.3.3' //new
I foolishly made the change while I was connected behind a hostile workplace proxy. The proxy caused the .jar files for the new version of gradle to become corrupt. This can be verified by inspecting the jars to see if they are an unusual size or whether they can be unzipped.
In order to fix the mistake, I connected to my network at home (which is not behind a proxy) and did a refresh dependencies from the Terminal:
./gradlew --refresh-dependencies
This caused the newer version of gradle to be re-downloaded and the error no longer occurs.
Check the spelling, mine was 'com.android.aplication'
This may also happen when you have both settings.gradle and settings.gradle.kts files are present in project root directory (possibly with the same module included). You should only have one of these files.
i had similar problem and i did following things to resolve it.
i referred to https://developer.android.com/studio/build
and copy / pasted these following lines before apply plugin lines
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
}
}
module app build.gradle file
apply plugin: 'com.android.application'
model{
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig.with {
applicationId "com.iamsafe"
minSdkVersion 15
targetSdkVersion 23
}
buildTypes {
debug {
minifyEnabled = false
useProguard = true
proguardFiles.add(file('proguard-rules.txt'))
}
}
}
}
dependencies {
compile 'com.android.support:support-v4:23.0.2'
compile files('libs/asmack-android-8-0.8.10.jar')
compile files('libs/commons-io-2.0.1.jar')
compile files('libs/httpclient-osgi-4.2.1-sources.jar')
compile files('libs/httpcore-4.3.2.jar')
compile files('libs/httpmime-4.1.2.jar')
}
project build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.10'
}
}
allprojects {
repositories {
jcenter()
}
}
In this case of issues check below code
dependencies {
classpath 'com.android.tools.build:gradle:**1.5.0**'
}
and gradle-wrapper.properties inside your project directory check below disctributionUrl:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
If these are not compatible with each other then you end up in this issue.
For com.android.tools.build:gradle:1.5. you need a version at least 2.8 but if you switch to a higher version like com.android.tools.build:gradle:2.1.0 then you need to update your gradle to 2.9 and above this can be done by changing distributionUrl in gradle-wrapper.properties to 2.9 or higher as below
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
If you work on Windows , you must start Android Studio name by Administrator.
It solved my problem
Just make sure you put the http and https proxy correctly when you create the app

Could not find build gradle 3.0.1

Any clarification on this subject would be greatly appreciated.
I know this has been answered many times but my current issue is that I don't know where or in what file (s) to add this to:
buildscript {
repositories {
...
google() // <-- add this
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
And this:
allprojects {
repositories {
jcenter()
google()
}
}
Or if that even solves my issue, since I haven't tested it yet.
My initial problem:
The issue seemed to appear after updating both gradle and Android studio.
I'm currently working on a project using libGDX to make an Android app called CastleCrush. When I try to launch a desktop application to test it, it won't launch, and I get this error:
Error:Gradle: A problem occurred configuring root project
'CastleCrush'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
file:/Users/TrulsElg/.m2/repository/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
file:/Users/TrulsElg/.m2/repository/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :
When launching with a virtual Android device it launches just fine.
I'm not working on this project alone and collaboration is done via Git, if that makes any difference. None of the other project members seem to have this issue.
You add this to your Project build.gradle file. its the gradle file that is called build.gradle(Project: your project name). It is usually the first one if you are in the Android project view
Could not find com.android.tools.build:gradle:3.0.1.
Gradle trying to find Android Gradle plugin version 3.0.1 artifact from your local maven repo (inside your computer) and from your listed three remote repository (maven2, oss.sonatype and jcenter).
But not succeeded because given artifact is not available on those repository.
Artifact com.android.tools.build:gradle:3.0.1 is available on google repository.
Find build.gradle file inside your libgdx project and add google maven repo inside allprojects tag
repositories {
mavenLocal()
mavenCentral()
maven { // <-- Add this
url 'https://maven.google.com/'
name 'Google'
}
}
If you're using Android Studio 3.0 or latter version
repositories {
mavenLocal()
mavenCentral()
google() //---> Add this
}
Make sure you're proper internet connection.
Cross-check that, you've not ticked offline work in Global gradle settings.
Before proceeding further take a look on LibGdx doesn't working after updating Gradle (Android Studio 3.0)

gradle project sync failed even after upgrading gradle plugin

Gradle project sync failed and did not get answers from other related questions. Here are the details of my situation.
Initial sync attempt yielded the following error message:
Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I have Android Studio 3.0. The build.gradle file includes the following dependency:
classpath 'com.android.tools.build:gradle-experimental:0.2.1'
The gradle-wrapper.properties file includes the following distribution URL:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
According to https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#update_gradle I need to make some changes.
First, update the Gradle version for Android Studio 3.0 in gradle-wrapper.properties:
distributionUrl=\
  https://services.gradle.org/distributions/gradle-4.1-all.zip
(I believe the backslash right after the equal sign is an error and did not make that change.)
Second, add the following buildscript repository to build.gradle:
google()
Third, change the build.gradle dependency:
classpath 'com.android.tools.build:gradle:3.0.1'
The second and third changes apply the latest version of the Android plug-in.
When I try to sync after these changes it fails again with the following new error:
Plugin with id 'com.android.model.application' not found.
The error refers to the first line of build.gradle:
apply plugin: 'com.android.model.application'
What is happening and why? I recently added NDK to Android Studio. The project I'm trying to sync includes C code. I'm not completely certain I added NDK correctly. I wonder if that could be part of the problem.
First, the gradle-wrapper.properties is incorrect. You must include \ in it. It should be something like this:
#Sat Jun 17 17:47:18 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Then, add the experimental classpath to project build.gradle. Something like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle-experimental:0.7.0-alpha4"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Check the Experimental Plugin User Guide for details.
Go to your build.gradle version or update it
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
You should change you dependencies classpath
All steps are here :
Open build.gradle and change the gradle version to the recommended version:
classpath 'com.android.tools.build:gradle:1.3.0' to
classpath 'com.android.tools.build:gradle:2.3.2'
Hit 'Try Again'
In the messages box it'll say 'Fix Gradle Wrapper and re-import project' Click that, since the minimum gradle version is 3.3
A new error will popup and say The SDK Build Tools revision (23.0.1) is too low for project ':app'. Minimum required is 25.0.0 - Hit Update Build Tools version and sync project
A window may popup that says Android Gradle Plugin Update recommended, just update from there.
Now the project should be runnable now on any of your android virtual devices.
Make sure your Gradle version is compatible with your Android Gradle Plugin.
https://stackoverflow.com/questions/24795079
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle

Update Android Studio Gradle plugin to last version

I'm new to Android developpement and I tried to install the Facebook SDK in my Android Studio project.
Then, I have a bug in build.gradle :
Error:(111, 0) Cannot call getBootClasspath() before setTargetInfo() is called.
So I searched for a solution and I found this on the stack:
This is a known issue , which is fixed by updating gradle to :
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
}
So I tried this but then I got the error:
Error:Could not find com.android.tools.build:gradle:1.1.2.
Searched in the following locations:
file:/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle/1.1.2/gradle-1.1.2.pom
file:/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle/1.1.2/gradle-1.1.2.jar
Required by:
Yoki:facebook:unspecified
So I moved into the specified directory and then there is only this:
$> ls
1.0.0 1.1.0
$> pwd
/home/roman/Documents/softs/android-studio/gradle/m2repository/com/android/tools/build/gradle
How can I update the gradle plugin?
Change your buildscript block. You have to specify also in this block the repositories.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.2'
}
}
Also you can use the last version:
classpath 'com.android.tools.build:gradle:1.1.3'
There are three type of dependency in Android gradle file.
1. Module dependency: other local project.
2. Local dependency: in your sdk path extras folder.
3. Remote dependency: JCenter, MavenCenter or third party maven path.
'com.android.tools.build:gradle' is local dependency, so you have to check your sdk and update.
P.S. If you tired with the version issue, you can try andle.
It's an open source project to update your Android dependency version automatically.
See https://github.com/Jintin/andle for more information

Android Studio doesn't find com.android.support:support-v4:19.1.0

I have imported one project into Android Studio but I got the error:
Could not find com.android.support:support-v4:19.1.0.
Where could I find this file? I have imported the project using Gradle.
I have the Android Studio version 0.5.7 the last android sdk and java 1.7u55.
Just add this code to you build.gradle file
dependencies {
compile 'com.android.support:support-v4:19.+'
}
and press Tools -> Android -> Sync Project with Gradle Files
Gradle will download necessary files by himself
It does not work for me either. It works with 19.0.1
But if (I use gradle) I do this in my build.gradle:
repositories {
def androidHome = System.getenv("ANDROID_HOME")
mavenCentral()
maven {
url "$androidHome/extras/android/m2repository/"
}
}
It finds the artifact.
From the SDK Manager, delete and re-install the Android Support Library 19.1 package.
I had this same problem with morning. I found the Jar file that I needed in /<MySdkFolder>/extras/android/support/ - in there are some sub folders with the different support libraries in them, so the last part of the path depends on which one that you want to use.
I just copied this into the lib folder of the project. I'm sure there is a more technical solution but it worked for me.
Following theory works at me:
Android Studio has problems importing support-v4:19.1.+ library when it comes through a transitive dependency.
Solution Adding support-v4 as own dependency and exclude this lib where it comes transitive. then i could not more see this import issue
Right clicking on the library and select the import as library option from the context menu works for me.
Try to go
Project Structure -> Dependencies -> Add : then select -> File
dependecies
then select the proper library
This artifact is available on google maven repository. So need to add following in the build.gradle:
allprojects {
repositories {
mavenLocal()
google()
}
}
I had a similar problem. This line to build.gradle works -->
implementation 'com.android.support:support v4:28.0.0'

Categories

Resources