In Android Studio, I get this error when I create a project:
Could not find com.android.tools.build:gradle:4.1.2.
Correct your app top-level build.gradle file and include Maven repo to download plugin from:
buildscript {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" }
mavenCentral()
}
}
Other option, it's possible to use beta version of Android Studio and upgrade to new version of AGP:
classpath 'com.android.tools.build:gradle:7.0.0-alpha07'
Related
I have installed Android Studio Dolphin RC1.
I am finding it difficult to configure the Firebase Firestore DB. Initial setup need to incorporate
Project-level build.gradle (/build.gradle):
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
...
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.13' - My problem
}
}
allprojects {
...
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
But the new IDE is not supporting it. This is the new Project-level build.gradle (/build.gradle):
. Where should I put the classpath?
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "TestApp"
include ':app'
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
// Added the dependency for the Google services Gradle plugin
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
...
repositories {
// Make sure that you have the following two repositories
}
}
Remove google() and mavenCentral(). Add the gradle dependency.
then use this version in gradle-Wraper.properties file.
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
I have failing build on a Bitbucket CI server:
> Could not resolve all artifacts for configuration ':classpath'.
> Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/aapt2-proto/0.3.1/aapt2-proto-0.3.1.jar
I searched similar questions that suggested the Google Maven repository is missing, but I am not missing it. Top level build file:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin"
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
And my app level build file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
}
dependencies {
classpath 'io.fabric.tools:gradle:1.26.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
google()
mavenCentral()
}
Try moving the google() method to the top of its execution block.
Maybe it's the order of repositories it searches in that causes the issue.
So for example, change this:
repositories {
maven { url 'https://maven.fabric.io/public' }
google() // from here
mavenCentral()
}
To this:
repositories {
google() // to here
maven { url 'https://maven.fabric.io/public' }
mavenCentral()
}
If that doesn't help, instead of calling the google() method, try changing it to this:
maven {
url 'https://maven.google.com/'
name 'Google'
}
UPDATE
If all of the above didn't help - make sure your gradle version is at least 3.0.0:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
And the gradle-wrapper version is at least 4.1:
Usually located here: project_name/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
Source
Upgrading the Gradle wrapper (in gradle-wrapper.properties) to gradle-4.10.2-all.zip fixed the problem to me.
Update Gradle Version
From the android gradle release page you can check compatible version for your gradle plugin.
Update gradle version in gradle-wrapper.properties located inside yourProject/gradle/wrapper
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.0-all.zip
Plugin version Required Gradle version
2.3.0+ 3.3+
3.0.0+ 4.1+
3.1.0+ 4.4+
Note that order matters. google() should be top of any plugin repo.
For Android Studio version > 3.0
buildscript {
repositories {
google() // move it to top
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' // your Android Studio Version
}
}
allprojects {
repositories {
google() // move it to top
jcenter()
}
google() plugin is needed since Android Studio version 3.0 or higher.
For Android Studio version < 3.0
buildscript {
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0' // your Android Studio Version
}
}
allprojects {
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
Problem
Due to a problem with jcenter repository I need to instruct gradle to use use maven repository. I could fix the problem changing the file build.gradle:
Original:
//...
buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
//...
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
//...
Modified:
//...
buildscript {
repositories {
mavenCentral()
maven {
url "https://maven.google.com"
}
jcenter()
}
//...
}
allprojects {
repositories {
mavenCentral()
maven {
url "https://maven.google.com"
}
jcenter()
}
}
//...
Since this file is not versioned, and per Cordova documentation, the way to extend build.gradle is to create a build-extras.gradle file, I've done so and have tried to add the same content I've modified in the build.gradle file, like:
build-extras.gradle
buildscript {
repositories {
mavenCentral()
maven {
url "https://maven.google.com"
}
jcenter()
}
//...
}
allprojects {
repositories {
mavenCentral()
maven {
url "https://maven.google.com"
}
jcenter()
}
}
Question
To sum up, changing the build.gradle file works but placing the same diffed content in build-extras.gradle it does not. Is there something that I'm missing?
Remove platforms and plugins folders (lets do everything from scrach so it's cleaner).
Do ionic cordova platform add android
Do cordova plugin add cordova-android-play-services-gradle-release --variable PLAY_SERVICES_VERSION=15.0.0 --fetch
Now finally you can do ionic cordova run android or ionic cordova build android
I have similar issue like here but in my case gradle cant't to resolve billing library v1.0 even if I add jcenter() repository into build script:
buildscript {
repositories {
mavenLocal()
mavenCentral()
google()
jcenter()
maven {url "https://maven.fabric.io/public"}
}
dependencies {
classpath "com.android.tools.build:gradle:3.1.0"
classpath "com.google.gms:google-services:3.1.0"
classpath "io.fabric.tools:gradle:1.24.4"
}
}
I found solution here. You need to add http://jcenter.bintray.com to repository list:
repositories {
maven { url "https://jcenter.bintray.com" }
}
I have a problem with android studio.
I will create a new project (without changing the parameter, just the next one), then I encounter these problems.
Go to your Project level build.gradle and add this after that sync
allprojects {
repositories {
jcenter()
google()
}
}
From version 26.0.0 of support libraries make sure that the
repositories section includes a maven section with the
"https://maven.google.com" endpoint.
Read Document
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
For Gradle build tools plugin version 3.0.0, you can use google()
repository:
Read Document
allprojects {
repositories {
jcenter()
google()
}
}