I am new to Android and WearOS and also to Gradle, and I just want to follow along this Codelab:
https://codelabs.developers.google.com/codelabs/watchface/index.html#0
So I downloaded Android Studio and imported the project
https://github.com/googlecodelabs/watchface
but when compiling I just get the error
Failed to resolve: com.google.android.support:wearable:2.0.0
I already tried to change SDK Versions and other things, but it didn't help.
I'm pretty sure it's just a few version settings, but I have no idea where to look.
Did anyone maybe complete this codelab and made it run with the "actual" version of AndroidStudio?
thanks,
Thorsten
The code on github was last updated in May 2017, which is a shame, as it is a useful introduction to watchfaces. A number of things have changed since then. There is even a pull request on github with gradle updates from Nov 2018, but it hasn't been merged.
Your 'Failed to resolve' error is likely related to Google now providing some packages in their own Maven repository, in addition to jcenter.
This can be fixed by adding google() to the repositories closures in the Package build.gradle file:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
The version of the gradle plugin has been changed to 4.0.2 above too, so also update the file gradle-wrapper.properties with:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Gradle should now build, but it may still log some warnings or errors in the Build window which you can open at the bottom of Android Studio.
The gradle dependency keyword 'provided' has been replaced with 'compileOnly' and 'compile' with 'implementation'. Shift+Ctrl+R in Android Studio will enable you to easily do the replacement project-wide.
It should also be useful for updating compileSdkVersion and targetSdkVersion (to 30) and buildToolsVersion (to 30.0.2) in all the module build.gradle files.
The package versions are out of date, with the wearable ones currently at 2.8.1 and play-services-wearable at 17.0.0. Ctrl+Alt+Shift+S takes you to 'Suggestions' in 'Project Structure', which can help you in future to stay current.
The last problem is that the Android Support Library has been obsoleted in favor of jetpack/androidx. See the old reference.
In this project, it is only a problem in the build.gradle of module 5-palette. You may replace 'com.android.support:palette-v7:23.3.0' with 'androidx.palette:palette:1.0.0'. See Jetpack Artifact Mappings. You then need to change the import statement in MyWatchFaceService.java.
Finally add the following line to gradle.properties:
android.useAndroidX=true
Related
I download tutorial codes from github, and I unzip it and copy paste it to where my android studio projects are. After I update to SDK 24.0.2, the project can be opened but can NOT be run now.
Pls write a bit more words for clear instructions in steps of what do I do since I am new to android studio. A lot of time I don't understand the terms you experts use.
Can NOT run the project? the green triangle run button is grey so I can NOT run it.
I got these red messages from Event Log
Gradle sync failed: Unsupported method: SyncIssue.getMultiLineMessage().
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.
Consult IDE log for more details (Help | Show Log) (41 s 341 ms)
I tried the repo and with only a few changes in two files was able to run the project.
update the root-level build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Updated gradle version to 4.2.1 and added google() to resolve android dependencies.
updated my gradle distribution URL in gradle-wrapper.properties.
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Please see if the 6.7.1 is supported on your android studio or not else update to the latest as per your android studio supports, mine is the latest hence 6.7.1
That is it, just by changing these two files I was able to run that app.
Note: I just did bare minimum changes just to make the app run, ideally all the dependency and everything should be up-to-date but changing all those is out of the scope of this question.
I even committed the changes in the forked version of the app code. feel free to try
https://github.com/dk19121991/Court-Counter
Gradle is an app that Android Studio uses to manage loading the libraries of code the project is built with (among other things). But since this project you downloaded is about 5 years old, the version of Gradle in the project may not match up with what Android Studio's Android plugin can support.
Typically, the Gradle app is actually part of the project. You'll see it in the gradle/wrapper directory in the project. You can update the version by editing the file gradle-wrapper.properties, by changing the value in the distributionUrl line. I think you need to make the version at least 6.7.1 if you have a recently updated version of Android Studio, so change that line to look like this:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
The configuration of the project is in the files named build.gradle. The weird thing is, that project seems to have an incorrect duplicate of build.gradle in the root directory of the project (it looks like the one that should go in the app directory). So you can delete the contents of that build.gradle in your root directory and replace it with what would normally be there in a new project. I just copy-pasted this out of a new project. You can paste it into that file:
buildscript {
ext.kotlin_version = "1.5.0"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.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
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And finally, you will want to update the build.gradle file that's in the app directory so it uses the version of Android you already have downloaded (probably SDK 30). So find these relevant lines in the file and change them:
compileSdkVersion 30
buildToolsVersion "30.0.3"
//...
targetSdkVersion 30
After you've made all the above updates, press the "Sync Project with Gradle Files" button near the right end of the toolbar to reload the project from Gradle. It will take a couple minutes because it will have to download the new Gradle version.
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 have just updated my android studio. The current version is Android Studio 2.0 Preview 6. However I am getting the message described in the title of this post.
I tried to play with the gradle version inside the dependecies of the gradle file,but nothing happens. Here is my file.
// 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.0.0-alpha6'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Is there any specific value of gradle that I should put,in order to fix the problem? Some people fixed it by using the version of gradle:1.5.0.
Thanks
Here is the full answer from my comments.
You need to use the same version of gradle for all submodules of your project.
You can see a list of submodules by choosing "Android" presentation in you Project View and expand "Gradle Scripts" section. You will see all build.gradles that are included into your project.
As of April 22nd, 2016 the latest beta version became
classpath 'com.android.tools.build:gradle:2.1.0-rc1'
And on June 3rd a stable 2.1.2 version was released which gives you the option to use
classpath 'com.android.tools.build:gradle:2.1.2'
Other answers here are correct but out of date, because this question does not get as much traffic.
This error indicates you are using a development environment that is far enough out of date that it could cause weird side effects, the solution is of course to upgrade to a more recent version.
When you use development versions, the error will reoccur as soon as your version is far enough behind the current version, which is why seasia's answer stopped working
I've been keeping an up-to-date list of the most current versions as well as the stable version on my answer to this similar question, so that I can fix it each time I get a new warning:
Android Studio 2.0 - Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE
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'
I updated the Android Studio version 2.0 and was using normally. When I created a new project today, it is displaying the error Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to
I realized that this problem occurs only when I create a new project. In previous projects developed, the problem does not occur and I realized that gradle is different
classpath 'com.android.tools.build:gradle:1.3.0'.
I have to update with the same set of old projects?
My app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "luizugliano.com.br.teste"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
My build.gradle (Project)
// 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.0.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
UH OH, Google Notice: "This website no longer provides downloads for Android Studio."
(Old 'channel' links no longer work. Links in this answer have been updated to the new formats, make sure to change your bookmarks if you were using them)
You need to update the version of the gradle tools you are building with. This can be found inside the dependencies section of your build.gradle. You have 3 options you can update to:
The latest stable version referenced in the release channel as of 2nd March, 2017 is
classpath 'com.android.tools.build:gradle:2.3.0'
Or the latest beta version via preview channel as of 15th February, 2017 is
classpath 'com.android.tools.build:gradle:2.3.0-beta4'
And the latest alpha version also from the preview channel as of 21st March, 2017 gives you the option to use
classpath 'com.android.tools.build:gradle:2.4.0-alpha3'
Updating requires you to also upgrade the gradle wrapper. As of 20th February '17, the newest is:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4-all.zip
On android studio you can find your wrapper by changing to the project view and looking in gradle/wrapper/gradle-wrapper.properties
Sometimes after changing wrapper the project will fail to compile with an error like “Minimum supported Gradle version is 2.14.1. Current version is 2.10. Try changing Gradle distribution version to...” despite already having the correct version in gradle-wrapper.properties. If that happens try the following:
Go to Settings > Build, Execution, Deployment > Gradle
Under Project-level settings ensure that Use default gradle wrapper (recommended) is the selected option, then re-build your project.
(Additional Note: With regards to the alpha and beta versions - there is not always a newer build than the stable version when I check, in those cases I've just given values for the previous version. This allows you to roll back to that version if you experience issues with the released version)
In new project change this part:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
with
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'.
If you're not experienced user, please stick with Android Studio's Updates Stable Channel. I suppose you got Android Studio from Canary Channel.
Note that:
The Canary Channel for Android Studio delivers the bleeding edge updates on a roughly weekly basis. While these builds do get tested,
they are still subject to bugs, as we want people to see what's new as
soon as possible.
From: http://tools.android.com/download/studio/canary
You don't need to change dependencies of your older projects. They should run normally on the latest version.
Same problem on update.
this Fixed it for me:[build.gradle]
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
or
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
Just in Advanced System Settings in Windows Properties, add a new environment variable with the name ANDROID_DAILY_OVERRIDE and the given value in error message. Restart android studio and you will be ready to go
As of April 5, 2016 this worked for me:
classpath 'com.android.tools.build:gradle:2.0.0-rc3'
gradle version you need became
classpath 'com.android.tools.build:gradle:2.0.0-beta7'
Which requires you to use the gradle wrapper for 2.10 if you were still using previous version
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
On android studio you can find your wrapper by changing to the project view and looking in gradle/wrapper/gradle-wrapper.properties
classpath: com.android.tools.build:gradle:+
This will solve the problem by updating gradle to latest one.
However it is dangerous(will code in alpha stage) & will also give warnings.
If you are using Android Studio 2.0 Preview I can suggest using 'beta' updates channel instead of 'stable'. It will allow you to receive latest gradle configuration changes. You can change updates channel in Settings - Appearance & Behavior - System Settings - Updates. Select Automatically check updates for [Beta Channel]
In order to know actual version of gradle classpath and distributionUrl (check Nick Caroso's answer) you can create new empty project and see these values there.
You need to change your gradle-wrapper.properties file in gradle/wrapper folder of your app, change your distributionUrl as this:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.8-all.zip
Use http: or https:\ as per your requirement.
Then just clean your project and you are done!!!
Side Note :
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
is available now, if you want to use latest version.
Also you can take advantage of instant run feature of android studio using this, which is not available in gradle version below 2.0.0
Android Studio 2.0 has an update project to use instant-run. For those like me with little brains:
http://tools.android.com/tech-docs/instant-run
The current version of Android Studio 2.0 is Beta 6.
try update gradle to 2.10
for mac, tha path is Android Studio > Preferences > Builds,Execution,Deployment > Build Tools > Gradle
of course you must download gradle 2.10 before
I got the same error on 04/07/2016 with
'com.android.tools.build:gradle:2.2.0-alpha2' and gradle wrapper 2.10
then, I just changed to
'com.android.tools.build:gradle:2.2.0-alpha3'
now I have no problems.
Hope this help peple.
I have resolved this way.
Steps:
Open gradle-wrapper.properties file and change distributionUrl to https\://services.gradle.org/distributions/gradle-2.14.1-all.zip.
Open root level build.gradle and change classpath to com.android.tools.build:gradle:2.2.2.
Sync your Android studio project.
Reference screen shot:
Done.
just change
classpath 'com.android.tools.build:gradle:2.0.0-alpha '
or
classpath 'com.android.tools.build:gradle:2.1.0'
I change my classpath from 'com.android.tools.build:gradle:2.2.0-alpha4'
to classpath 'com.android.tools.build:gradle:2.2.0-alpha5'
and clicked "try_again" when the warning appears "unable to find cached classpath" you just click "sync", this worked like a breeze.
This problem occures generally when the IDE(android studio) in which project is build and the project are not in compatible gradle plug in. Please check the link below
http://tools.android.com/tech-docs/new-build-system/version-compatibility
In my case i had created a project using AS 1.0/2.0 version, and later imported in studio version new it gave me error then I opened project in older version of AS it worked.
you can also check http://tools.android.com/tech-docs/new-build-system
File -> Project Structure -> Project -> Android Plugin version = 2.2.3
Working fine of Android Studio 2.2.3