I really do not understand why it was always so much trouble of adding Gradle plugin in the Android app.
I started my project by creating a fresh app.
This is in my gradle.properties:
distributionUrl = https \: //services.gradle.org/distributions/gradle-3.0-all.zip
and this project and says build.gradle:
buildscript {
repositories {
jcenter ()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0'
}
}
and the error I get is
The build tools for Android do not support version 3.0 at present.
If you check the gradle build tool project on Bintray, you can see the latest available versions.
At present, that is 2.2.0-rc1 so to use it you should add this to your project-level build.gradle:
compile 'com.android.tools.build:gradle:2.2.0-rc1'
If you want to use the latest stable version 2.1.3 replace it with,
compile 'com.android.tools.build:gradle:2.1.3'
You should also checkout tools.android.com for the latest up-to-date information on the Android Build Tools
Related
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
I updated the android studio to 3.1.1 and android sdk as follows
androidMinSdkVersion = 16
androidTargetSdkVersion = 27
androidCompileSdkVersion = 27
androidBuildToolsVersion = "27.0.3"
androidSupportV7LibraryVersion = "27.1.1"
I am able to build and run apk on device but editor not able to recognize third party imports and shows red color for imports and for usage
event after invalidating cache issue is not yet solved
Gradle version is as follows with 4.4 distribution
classpath 'com.android.tools.build:gradle:3.1.1'
dependencies are already changed from from compile to implementation
This issue is not limited to one library having same issue to all the third party dependecies such as Volley , circularimageView etc
Update
I am getting this pop up when doing installdebug which says gradle 3.1.1
Typically, this error occurs when you have a compilation error elsewhere and your cleaned project can no longer be compiled. I suggest trying a gradle build from the command line, and editing your post to include the log output.
As of this post 3.1.1 Gradle Plugin doesn't exist in the documentation.
The plugin does not always match Android Studio versions.
To match the documentation, make your top level build.gradle match this
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
}
Also, Gradle version as of this post is 4.6
I have an Android studio project that wrote in Android Studio version 1.3.2. Now in another PC with Android Studio 2.1.2 I want to import or open that project to it. But when I try, and while opening, error occurred with my Gradle version and want from me to download necessary Gradle version.
But for my reasons, I don't want to download new data with Android studio. how can I manually transfer old PC Gradle to new one? or is there simpler way to resolve that?
Method: 1
Try "File -> New -> Import Project"
or Create new project and copy-paste all project files(Java,XML,Resource) except gradle folder.
Method :2
Or After Import file just change 2.1.2 to 1.3.2
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
Adding local Gradle to projects would be really helpful
1.Download Gradle http://www.gradle.org/downloads
2.Install
3.Set Gradle home to the install directory like below :
there is sample project check it : https://github.com/foragerr/SO-35302414-local-gradle-plugin
Open your app level build.gradle file and change the gradle version accordingly like
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
so just change your version from 1.3.2 to 2.1.2
1.I faced same problem before .Ok you need to copy .java file and .xml layouts strings,colors,dimen,drawble images and others in old project
2.And create new android project in your new android studio and paste that file into that project that's it
NOTE: Copy only required files only
Try "File -> New -> Import Project" or just create new project and just copy-paste all project files except gradle folder (change gradle version in build.gradle after copy)
You Need To Check This From Google Android.
Plugin version Required Gradle version
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3+ 2.14.1+
So You Cannot Use Old Gradle Build With new Android Studio Version According to Google.
You Can Use the Older Version of Of Android Studio to Make Your Project Work With the Old Gradle System
Look in the SDK Manager what is your highest Android SDK Build-tools version, and copy this version number in your project build.gradle file, in the android/buildToolsVersion property The Build Tool Version Propert Should Be Compatible With the Gradle.
2 ways you could choose to give a try, either of them is okay for me:
1.Copy files and make some configurations:
create a new empty Android project, copy only java source files and layout\drawable\colors\dimens etc but Not exclude AndroidManifest.xml files copy into your new project
override the AndroidManifest.xml's application tag with the content of the old project's(only )
build the new project, you will meet some 'Not Found' errors, modify package names and path of some files until errors disappear
done!
2.edit some of gradle files:
modify contents of "/Users/your_name/your_project_directory/gradle/wrapper/gradle-wrapper.properties(path could be different on windows)" , notice distributionUrl="something like https://mirrors.somewhere.net/mirror/gradle/gradle-xx.xx-all.zip", xx.xx determines the version of gradle the project used
modify contents of "/Users/your_name/your_project_directory/build.gradle" and any modules included in your project will have their own build.gradle file, notice the following:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:xx.xx.xx'
}
}
Then change 'com.android.tools.build:gradle:xx.xx.xx' which determines the Plugin version to the version corresponding to the version of 'gradle-xx.xx-all.zip' which determines the Gradle version as #AndroidHacker's post:
Plugin version Required Gradle version
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3+ 2.14.1+
done!
first thanks for your answers. but I finally find the solution to solve this issue without download anything and just with a few changes in versions and files.
1- Open project folder then /gradle/wrapper/gradle-wraper file.
2- In this txt file, change distributionUrl value to: https\://services.gradle.org/distributions/gradle-2.10-all.zip
3- Back to Android Studio.In your project's build.gradle file, change classpath to com.android.tools.build:gradle:2.1.2
4- In your app's build.gradle file, change buildToolsVersion to "23.0.3"
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
I just spend some time and failed trying to migrate an existing android studio project from gradle 1.8 to gradle 1.9 final ( which was released yesterday 19th Nov ).
I read most of the other gradle related posts here but none worked for me.
here a list of what I've tried so far:
./gradle/wrapper/gradle-wrapper.properties changed distributionUrl to gradle-1.9-all.zip
Rebuild Project
in android-studio: Tools -> Android -> Synch Project with Gradle Files
running command gradle wrapper in project dir to update the wrapper
-
build.gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
all ended with the "need gradle 1.8, change your gradle-wrapper.properties to gradle-1.8-all.zip" error message.
Gradle 1.9 isn't supported with the Android plugin 0.6.3; it requires 1.8. The plugin uses internal Gradle APIs and is tied to specific Gradle versions to ensure it works. This limitation will be lifted in the future, but will require some new features in Gradle.
The next version of the plugin will support Gradle 1.9.
EDIT:
Android Studio 0.4.0 and Android Gradle plugin 0.7.0 have been released; these support Gradle 1.9. At the time of writing, Gradle 1.10 is current, but is not supported yet in v0.7.0 of the plugin.
You could try this:
Close your Project and try to open your project, but instead of choosing the root folder of your project choose your settings.gradle file.
AS will ask you if you want to open this project -> click "Yes". Than a window appears "Import Project from Gradle". Make sure that "Use default gradle wrapper" is selected.
This helped me after upgrading AS to 0.3.1, since this version you need gradle 1.8.