Gradle and latest version of libraries - android

Why does Gradle not show latest versions of used libraries? For example latest versions of ExoPlayer is 2.9.4, BlurView - 1.5, Android Billing Client - 1.2.1, but Gradle allows to add only 2.8.4, 1.2, 1.0 for these libraries.

As per today's date the latest gradle version is:
classpath 'com.android.tools.build:gradle:3.3.1'
After updating gradle, Try following things to see updated versions with yellow marks in build.gradle.
Invalidate Cache and Restart
or
Close and open again build.gradle
Hope it will get refreshed and display latest versions.

Related

Android Studio, Unable to migrate to AndroidX

I'm having the following error message when trying to do refactor -> migrate to AndroidX
The gradle plugin version in your project build.gradle file needs to
be set to at least com.android.tools.build:gradle:3.2.0 in order to
migrate to AndroidX
Although I have version higher specified in build.gradle...
app/android/build.gradle
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
I have another app/android/app/build.gradle.
I solved it by changing version to 3.4.1 and back to 3.4.2.
now error is gone..
in my case,
apply
classpath("com.android.tools.build:gradle:4.0.1")
instead of
classpath("com.android.tools.build:gradle:${version.gralde}") -> even version.gralde is 4.0.1
:thinking :) maybe android studio can't identity the plugin version if it references to an external value
Only change gradle version of a project may be not enough. Please also check gadle versions of the dependies. Make sure every gradle version of a depency is beyond 3.2.0. Have a try, please.

Gradle build failing with fabric crashlytics when minify is enabled in Android studio version 3.2 and Gradle version 4.6

Getting the following errors after applying proguard rules:
Could not find method create() for arguments
[crashlyticsStoreDeobsRelease, class
com.crashlytics.tools.gradle.tasks.StoreMappingFileTask,
com.android.build.gradle.internal.scope.BuildArtifactsHolder$FinalBuildableArtifact#1711854a]
on task set of type
org.gradle.api.internal.tasks.DefaultTaskContainer.
It looks like the version of fabric build tools in your build.gradle is set to something like classpath 'io.fabric.tools:gradle:+' which means it always uses the newest available version.
The current version 1.26.0 seems broken so you can temporarily set exact version to 1.25.4: classpath 'io.fabric.tools:gradle:1.25.4'.
Checked a couple of minutes ago, it works.
UPD: new version io.fabric.tools(1.26.1) is released. classpath 'io.fabric.tools:gradle:+' now works well

Google play services version automatically changes to 11.8

Recently i upgraded my project to android studio 3
In my build.gradle , i have: compile "com.google.android.gms:play-services-maps:10.2.1"
So it must use gms 10.2.1 , but in "#integer/google_play_services_version" i have following:
<integer name="google_play_services_version">11910000</integer>
And in the project --> External libraries i can clearly see that it compiles gms version 11.8:
Why this happens?
Use ./gradlew dependencies to check the dependency tree.
You are simply using a library that has a dependency with 11.8.0 and gradle uses the newest version.

Android Studio 2.0 - Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to

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

Android grade syntax and build tools compatibility issues

I didn’t work full-time with Android in the last couple of years, and now whenever I try to fork someone code on GitHub I get a lot of errors since android tools and Gradle syntax are changing frequently.
I wonder what is the best way to handle these changes, and be able to upgrade other GitHub projects and some of my old projects to work with the latest Android tools. Here are some of the things that I struggle with:
I noticed some of the issues are related to changes in the Gradle syntax. How can I know what Gradle version the build.grade syntax was written with? and then how to upgrade it to the current version (is there a migration guide for Gradle versions?).
Sometimes I get issues related to tools that are not compatible with others, how can I know which version are compatible with which? and whats the easy way to manage that? here are some of these tools:
Gradle
Android Plugin for Gradle
Build Tools
Android Studio
How can I know what Gradle version the build.grade syntax was written with?
If the project contains a gradle/wrapper/gradle-wrapper.properties file, that is the version of Gradle that the developer of the project is using.
is there a migration guide for Gradle versions?
I am not aware of much Gradle syntax that would have changed that would affect Android developers for garden-variety projects. Most of the changes are from the DSL added via the Gradle for Android plugin. You can find the version of the plugin that the project developer was using via the classpath statement in the project's top-level build.gradle file.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
The above snippet is requesting version 1.3.0 of the Gradle for Android plugin.
Migration documentation for the Gradle for Android plugin is minimal. What there is can be found up on http://tools.android.com.
how can I know which version are compatible with which?
Here is Google's statement on the issue, though this has not been updated in a few months.
and whats the easy way to manage that?
If the tools complain, change them to a set that you know is good (e.g., by copying values from a known-working project). If you need something that was introduced in a newer version of the tools, change them to a set that you know is good. Otherwise, don't worry about them.

Categories

Resources