While building a default project (black template) on Android Studio 3.0 Canary 1, I got the below error.
The android gradle plugin version 3.0.0-alpha1 is too old, please update to the latest version. To override this check from the command line please set the
ANDROID_DAILY_OVERRIDE environment variable to "d27b293f4c7c48dfe922ba160164f3fa511cb3b9"
Upgrade plugin to version 3.0.0-alpha1 and sync project Open File
What's wrong with the default setting?
Your code may be containing an outdated gradle plugin version (may be alpha1, or something like that) in your project build.gradle file. Update it to the latest alpha4 plugin like below:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
}
Apparently, the alpha1 is obsolete, even though it is not mentioned anywhere in document I could find.
In the project build.gradle, just change from
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
to
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
classpath 'com.android.tools.build:gradle:+'
its not recommended to use +
Follow the steps :
Go to your Project structure
Click on project on left side panel
Update the Gradle version to 3.3
Click on Ok Button
let it sync and you will be done
After trying this solutions, I came with this:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha4'
}
}
add
maven { url 'https://maven.google.com' }
to buldscript repositories.
Related
I am getting the following error suddenly while building Ionic 3 app for Android.
Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.60-eap-25
We have one solution from Android Studio here but after I did change in my build.gradle with the following code I am still getting the error.
buildscript {
repositories {
...
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
allprojects {
repositories {
...
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
My build.gradle file looks like this after I updated my Cordova and added the above solution.
buildscript {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
dependencies {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:3.3.0'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
//This replaces project.properties w.r.t. build settings
project.ext {
defaultBuildToolsVersion="28.0.3" //String
defaultMinSdkVersion=19 //Integer - Minimum requirement is Android 4.4
defaultTargetSdkVersion=28 //Integer - We ALWAYS target the latest by default
defaultCompileSdkVersion=28 //Integer - We ALWAYS compile with the latest by default
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Still the same error.
The problem lies in the cordova-support-google-services plugin for Cordova.
This plugin's build.gradle looks like this as of today (October 24th, 2019):
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
}
More exactly the problem lies in this dependency:
classpath 'com.android.tools.build:gradle:+'
That is an extremely brittle way of specifying dependencies. The '+' sign here means "fetch the most recent version available in the repo".
If a newer version is published in the repo, and it breaks the build, then everyone with this plugin has their projects broken.
This happened today. The broken version that is being fetched is com.android.tools.build:gradle:4.0.0. It requires some Kotlin stuff.
That is why you need to ALWAYS freeze dependencies to reliably build your project. Never trust the newer stuff. This dependency compiles fine just as it did yesterday:
classpath 'com.android.tools.build:gradle:3.5.1'
For those using Cordova or Ionic, you can make a quick fix to be able to build the project by freezing the dependency in the file:
<projectroot>/platforms/android/cordova-support-google-services/<project>-build.gradle
This is not a definitive solution though. If you reinstall the android platform via Cordova the error will show up again. The project maintainer should either freeze the dependency or fix it to support gradle 4.0.0.
In the meantime just use a fixed fork of this plugin.
EDIT 10/28/19:
cordova-support-google-services was updated today to version 1.3.2 which changes the classpath from
classpath 'com.android.tools.build:gradle:+'
to
classpath 'com.android.tools.build:gradle:3.+'
which seems to fix the kotlin error
Original Answer
I got mine to build successfully by doing the following:
I edited
platforms->android->cordova-support-google-services->myAppName-build.gradle
and changed
maventCentral()
to
maven { url "https://maven.google.com" }
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
That solved the kotlin error then I was getting a different error that I resolved by changing
classpath 'com.google.gms:google-services:4.2.0'
to
classpath 'com.google.gms:google-services:4.1.0'
It then built successfully.
Here is the solution.
The problem was exactly the maven repository (here), but the issue was with the build.gradle from the cordova-support-google-services plugin, so I added the required line and everything is ok now, I've already created a pull request to the original repo (here). But in the meantime you can do what I did, just replace in the package.json the current versiĆ³n with my repo:
Before:
...
"cordova-support-google-services": "^1.3.1",
...
After:
...
"cordova-support-google-services": "https://github.com/LuisEGR/cordova-support-google-services.git",
...
after that you will have to:
Remove folders platforms and plugins
run npm install
This is a temporal solution while the pull request to the main repo gets accepted and the npm package updated
and that's it, now you can build your project again.
I'm using Ionic 4, and some plugins require cordova-support-google-services, in case you don't have it in your package.json the error could be with another plugin, if so please add the package.json so we can find out which one is the problem.
UPDATE 24/OCT:
I've changed the solution in my repo as many of you suggested, now the solution consinst just in fixing the dependency: from: com.android.tools.build:gradle:+ to classpath com.android.tools.build:gradle:3.+, this is already in my repo if you want to see what's changed
in my project i fix like this.(my project in kotlin)
buildscript{
repositories {
google()
jcenter()
......
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
allprojects {
repositories {
google()
jcenter()
......
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
}
}
Solution for ionic v3 and cordova
#Mister Smith solution solved my problem
you have to go to the file
platforms/android/cordova-support-google-services
then
Replace
classpath 'com.android.tools.build:gradle:+'
by
classpath 'com.android.tools.build:gradle:3.5.1'
#Alternative solution I have found is to
setup kotlin in your system :)
As a further temporary fix to follow-up on the suggestion from #MisterSmith, use a hook to re-apply the lock:
<hook src="scripts/fix_android_dep.sh" type="after_platform_add"/>
with this overly wordy bash code:
#!/usr/bin/env bash
## temporary fix for android studio EAP issue
## SOURCE: https://stackoverflow.com/a/58536638/56545
if [ -d "platforms/android/cordova-support-google-services" ]; then
file="platforms/android/cordova-support-google-services/app-build.gradle"
from="classpath 'com.android.tools.build:gradle:+'"
to="classpath 'com.android.tools.build:gradle:3.5.1'"
change=`sed "s/$from/$to/" < "$file"`
echo "$change" > "$file"
fi
I had to add maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' } both into the top-level build.gradle and into the app module build.gradle.
In both cases both into the buildscripts.repositories and in allprojects.repositories
None of the above worked for me. I ended up removing the google-services plugin and add it.
cordova plugin rm cordova-support-google-services
cordova plugin add cordova-support-google-services
In my case I had the same error first, then a whole bunch of other packages (org.ow2.asm:asm-analysis:4.0#jar, etc...) that could also not be resolved.
The problem was that I upgraded Gradle to v5 (to be able to support the new version of Crashlytic). Doing so, I upgraded the repository to Google(), and deleted the old maven { url ... } entries.
But I also deleted jcenter(), which was still required for a lot of nodes.
Now my repository section looks like this:
buildscript {
repositories {
maven { url "$rootDir/../node_modules/react-native/android" }
google() // Google Maven repository
jcenter()
}
//...
So if someone else is reading this but was not happy with the current accepted solution of downgrading Gradle, check if you have jcenter().
Ps.: I realize this is an old issue but I recently found it while searching on google.
I was following a tutorial to develop icon pack for android and when I imported the project I got several errors and it was solved here - Gradle Version 4.6 - Absolute path are not supported when setting an output file name
After solving that error, the following error poped up.
Could not find com.android.tools.build:aapt2:3.2.0-4818971.
Searched in the following locations:
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/google/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
file:/C:/Users/Tomin Jacob/AppData/Local/Android/Sdk/extras/android/m2repository/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jcenter.bintray.com/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971.pom
https://jitpack.io/com/android/tools/build/aapt2/3.2.0-4818971/aapt2-3.2.0-4818971-windows.jar
Required by:
project :licensing
I tried to open the URLs and I was able to download JAR (aapt2-3.2.0-4818971-windows.jar) and JSON (aapt2-3.2.0-4818971.pom.json) files from the first 2 URLs. Should I copy these files somewhere? What should I do to solve this error?
Most likely you do not have the Google repository in your project's build.gradle file. Add google() in BOTH locations as shown below:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I was able to solve the issue by adding google() in both locations:
File -> Project Structure -> Project -> *Now add ", google()" in
Android Plugin Repository
and
Default Library Repository
*
When you upgrade to 4.6 version of gradle. You need following upgrades too. Gradle Plugin Release page.
1. Android Studio 3.+
You need Android Studio version 3.+ to have 4.6 version of gradle. At the time of post latest release was 3.2.1. You can see latest release on this page.
2. Gradle Plugin 3.1.+
You need 3.1.+ gradle plugin for gradle-4.6 support. Check in project level build.gradle.
classpath 'com.android.tools.build:gradle:3.2.1'
At the time of post latest version was 3.2.1. You can see latest release here.
3. Add Google Maven Library
You need to add Google Maven library to project level build.gradle like below code.
buildscript {
repositories {
google()
...
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
...
}
}
allprojects {
repositories {
google()
...
}
}
see the dependencies of module :licensing and use com.android.tools.build:aapt2:3.2.0 (or even "com.android.tools.build:aapt2:3.2.0:windows") there, which is the final version ...that 4818971 version should ordinary come with an alpha prefix/suffix (the version number seems to be incorrect). maybe adding repository google() might be required, too. ordinary, that dependency should be present; removing that dependency might be another possible option.
For those people who still face exactly the same problem even after adding two google to BOTH positions in relevant gradle file.I would suggest you to check Android Studio -> Preferences -> HTTP Proxy page.
If you find it says some warnings like "...have set JVM proxy to 127.0.0.1".Then you should consider vpn-related issues which depends on your context.
If your desktop is MacOS, then go to Network setting page, advance->proxy tab,uncheck all the checkbox there.
Back to your IDE as following steps: Android Studio->File->Invalidate Caches/Restart.After that,go back to check Android Studio -> Preferences -> HTTP Proxy page again,previous warnings should be gone.Run again.
I solved my issue by upgrading my classpath from
'com.google.gms:google-services:4.0.0
to
'com.google.gms:google-services:4.2.0'
hope this helps
I just updated to Android Studio 3.0 and I'm getting this error with an existing project:
Kotlin not configured
When I go to Tools>Kotlin>Configure Kotlin in Project, I get an error saying "no configurators available". Also get the error below with the red java:
I've also tried:
Restarting
Clean and Rebuild
Invalidate caches/restart.
I first tried with invalidate cache/ restart option but it doesn't help me.
When I updated Kotlin to 1.1.60 in project's gradle file, problem is solved.
Also, use this in app's gradle for stdlib
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.1.60"
instead of
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.60"
In Android Studio, click on File -> Invalidate Caches / Restart... , then select "Invalidated and Restart". This solved my problem.
This error also occurs if you have the mavenCentral() repository missing in allprojects.
Your build.gradle (:app) should contain at least this:
allprojects {
repositories {
google()
mavenCentral()
}
}
jcenter() would work as well (for now), but that repository reached end-of-life and shouldn't be used any more.
Closing and restarting Android Studio works for me in that case. Important is that there are no other projects opened in Android Studio before you close it. I suspect that closing Android Studio with multiple opened project windows sometimes messes up the configuration especially after plugin upgrades etc.
Important Update
You should check JDK version before setting config
Kotlin gradle config page has detailed information about this.
Step 1
Check kotlin version in project level gradle file.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
For kotlin_version '1.2.x' Use jdk NOT jre
Step 2
Check JDK version in File > Project Structure
Or check in build.gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
If no JDK version is set in Project Structure, then choose by Android Studio version
JDK version is 1.7 for Android Studio Version < 2.2.1
JDK version is 1.8 for Android Studio Version < 2.2.1
Because Android Studio is bundled with jdk 1.8 since 2.2.1 version.
You have 3 options of kotlin stdlib, choose according JDK version
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" //jdk_version == 1.8
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" //jdk_version == 1.7
implementation"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" // jdk_version is < 1.7
if kotlin version is'1.1.x' Use jre NOT jdk
implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" // or jre8
Update Kotlin Version?
You can update Kotlin version from Tools > Kotlin > Configure Kotlin Updates
Kotlin-stdlib-jre7 is deprecated since 1.2.0 and should be replaced with kotlin-stdlib-jdk7
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
I have faced this issue recently... when I updated to Android Studio 3.1 .
I did a few things to fix this.
First I updated the Kotlin version in my app gradle file and added
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.31"
in my app gradle file. But this alone didn't fix it.
Then uninstalled the kotlin plugin from settings, restarted Android Studio and installed it again.
EDIT :
This is my project gradle file
buildscript {
ext.kotlin_version = '1.2.31'
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.31"
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
google()
}
}
And this is my app gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
...
}
buildTypes {
...
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
kapt { generateStubs = true }
}
repositories {
...
}
dependencies {
...
...
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.31"
...
...
}
apply plugin: 'com.google.gms.google-services'
just delete .idea folder from project,and run android studio again, it will resolve KOTLIN NOT CONFIGURED issue.
A common reason of the "Kotlin Not Configured" message is an internal Android Studio exception due to a bad plugin.
In order to fix that you should disable the bad plugin.
When such plugin crash occurs, on the "Wellcome screen" you'll see a small notification (see illustration image) where you can click it and disable the bad plugin:
None of the other solutions solved my problem. I ended up figuring out that the problem lied in the google services version. Just update it to the latest.
Top level gradle at dependencies:
classpath 'com.google.gms:google-services:4.1.0'
In my case, after the update of Android Studio and plugins, I could create new projects, but my old projects were having "Gradle Sync Issues".
The solution was in File/Project Structure.../App/Dependencies:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
And then I just updated the Kotlin version in my project build.gradle:
From:
ext.kotlin_version = '1.2.30'
To:
ext.kotlin_version = '1.3.21'
Then I tried Sync again.
Obs: You can check your Kotlin version in Tools/Kotlin/Configure Kotlin Plugin Updates
I have tried all above solutions but non of them works for me.
Then finally I got success with below solution, so it may helpful for some one like me.
Delele all .iml files (in root project, libraries and modules)
Rebuild project
In my case I had to update Android studio from version 3.4.1. to 3.5 and it resolved the kotlin not configured error.
Delete .AndroidStudio3.6 folder in C:\Users\Username and re-open Android studio works for me
The only fix for me was adding
apply plugin: 'kotlin-android-extensions'
in build.gradle (:app)
One other point to check is version of your Gradle in gradle-wrapper.properties, if you use one.
Make sure that
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Has version 4.1 or higher.
You may also have the following in your build.gradle:
task wrapper(type: Wrapper) {
gradleVersion = '4.1'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
Where Gradle version is lower that 4.1
Though I see that the question already has answers that work, one might also try the following solution.
Right click on the file name (Main.kt) -> Run 'Main.kt'.
This will download a gradle file from the gradle.org website.
Wait for it to unzip. The errors were cleared.
In my case, it was a broken update of one of the plugins I've used. Check your error logs from Android Studio this will lead you to what is the problem.
Simply Create a new Activity and select its language to kotlin Android studio Automatically configured kotlin for you.
Today I update my android studio from 2.0 to 2.1
when I rebuild my project,there are some error like this:
some error
I use data binding in my project.When I use Android studio 2.0,everything is ok.
I find that,there is no databinding1.1 in jcenter
https://jcenter.bintray.com/com/android/databinding/
the newest version is 1.0
how can i fix it
I have the same question and I updated Google Repository and Android Support library in SDK Manager,it works for me.
I know how to fix this.
there are some problem in gradle2.1
I update my Android Gradle plugin to version 2.1.0
when I set the Android Gradle version to 2.0,every thing is ok.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
I was syncing fine and then suddenly when I tried to run a test on a device from Android Studio I started getting the error:
Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable ...
I've looked around and I found from the gradle website that the latest version is 2.10, I tried adding that to my dependencies with no luck. I've tried various version numbers with various errors like the following:
Could not find com.android.tools.build:gradle:2.1
Searched in the following locations ...
I understand from all the searching I've done that its clearly a wrong version of gradle - but what IS the current version label I should be using, and how do I know it is installed on my machine ? I've always kept Android Studio updated.
So I currently have in the build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
}
UPDATED (28/03/2017):
2.4.0-alpha3 is the latest release
classpath 'com.android.tools.build:gradle:2.4.0-alpha3'
Check https://bintray.com/android/android-tools/com.android.tools.build.gradle/view for the latest gradle versions.
2.0.0-alpha1 is on the Canary channel and apparently these releases come with an expiry date. 2.0.0-alpha3 is the latest release. Switch to
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
and you should be fine. Keep checking http://tools.android.com/tech-docs/new-build-system to know the latest releases.
You might run into some Dex error. I had to do Build > Clean Project once to get it to work.
Change your existing configuration with this
In your project view, select Gradle Scripts
Open gradle-wrapper.properties
Change this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Go to build.gradle (Project: your_app_name)
Change this line
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
to this
classpath 'com.android.tools.build:gradle:1.5.0'
Don't click Sync Now
From menu choose File -> Invalidate Caches/Restart...
Choose first option: Invalidate and Restart
Android Studio would restart. After this, it should work normally
Hope it help
Now com.android.tools.build:gradle:2.0.0-alpha3 is old
use this
com.android.tools.build:gradle:2.0.0-beta2
If your having trouble getting the plugin to resolve. Check that your including jcenter() (Jcenter) in your repositories for the buildscript. Google does not publish the plugin to mavenCentral() (Maven Central).
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}
}
As others have mentioned the latest ATM is 2.0.0-alpha3 but that could change at any time. Here is the source of truth on the latest available version:
https://jcenter.bintray.com/com/android/tools/build/gradle
As for the actual error here is the best answer is in is link. TLDR, undocumented feature of the non release plugins is they expire and you have to update.
https://stackoverflow.com/a/31293869/873237
Just solved by doing the following steps:
1 - Open gradle-wrapper.properties
Replace
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
2 - Open build.gradle (Project: app_name)
Replace
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
with
classpath 'com.android.tools.build:gradle:2.2.1'