I know that the Android Plugin version and the Gradle version
have to "match", or it wants you to use a specific version of Gradle.
So my question is, how can I find what version, '0.9.2', of the Android Plugin
it wants in:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.2.+'
}
}
apply plugin: 'android'
I've found that if the version is "close enough" it will download/update what
it needs to make it happy, otherwise it'll give you an error.
So is there any command I can issue, or file to look at, that will
tell me what version to put in place of '0.9.2' so that I can
do a 'gradle build' with the version of Gradle that I have installed?
And I want to be able to just run 'gradle' and not 'gradlew.bat'
Thanks!
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
After couple of months of not working on my app I have decided to continue and before doing so I wanted to update all dependencies, libraries etc.
After 3h+ of a nightmare with googles nonsense I am at the final (probably not even close) stage.
This error of:
The Android Gradle plugin supports only Crashlytics Gradle plugin
version 1.25.4 and higher.
Is driving me nuts. I did a global search on my project of 1.25.4 and 1 result came up which was for the classpath 'io.fabric.tools:gradle:1.25.1' so I changed it to classpath 'io.fabric.tools:gradle:1.25.4' and hoped for the best.. But the same error keeps coming up every time I am trying to build the app..
Can anyone tell me what kind of magic potion should I spray this gradle so it actually starts to work?
add this to the root project's build.gradle:
buildscript {
repositories {
...
maven { url "https://maven.fabric.io/public" }
}
dependencies {
...
classpath "io.fabric.tools:gradle:1.26.1"
}
}
and this on top of the module level's build.gradle:
apply plugin: "io.fabric"
I have copied and compiled the source code for speech api last month on this location https://github.com/GoogleCloudPlatform/android-docs-samples/tree/master/speech/Speech
and works. Now, when I revisited it, I'm having a Configuration with name 'debugAndroidTestCompile' not found. error.
What is causing this? If you ask me how did I know it is the one, I did the process of elimination. I removed one by one on the gradle file and sync. When I removed apply plugin: 'com.google.protobuf' the error disappears.
Update the protobuf version to the latest in build.gradle. Currently it's 0.8.8, check the latest version from the GitHub repository Protobuf Plugin for Gradle.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
}
}
I have this problem. I downloaded this API from https://github.com/tlaukkan/zigbee4java
I tried several times to import the project on Android Studio 2.3.1 but always Gradle fail to sync with this Error:Configuration with name 'default' not found.
I read on other posts about this error but I do not understand what to change because this API should be correct.
Thank You for support.
Best Regards.
EDIT
these are the steps I did:
- unzip file
- open Android Studio
- select Import Project (Eclipse ADT, Gradle, etc.)
- I select zigbee4java-master
- and then Start Gradle Build
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
build.gradle
import org.codehaus.groovy.tools.StringHelper
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
def zigbee4javaProfilesArray=StringHelper.tokenizeUnquoted(zigbee4javaProfiles)
group = 'org.bubblecloud.zigbee4java'
apply plugin: 'java'
apply from: 'build-common.gradle'
/* Include build scripts from all profiles selected in 'gradle.properties' */
allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url "http://repository-bubblecloud.forge.cloudbees.com/release/"
maven { url "http://repo.maven.apache.org/maven2" }
}
}
dependencies {
for (zigbee4javaProfile in zigbee4javaProfilesArray) {
switch (zigbee4javaProfile) {
case 'android':
println 'zigbee4java: Including Android build'
compile project(':zigbee-serial-android')
compile project(':zigbee-console-android')
break;
case 'javase':
println 'zigbee4java: Including JavaSE build'
compile project(':zigbee-serial-javase')
compile project(':zigbee-console-javase')
break;
}
}
}
I hope these informations are correct to understand my problem.
Thank You
EDIT
About GRADLE 3.0 problem I tried this:
on Settings I set "Use a local Gradle Distribution" and I set the path to a downloaded Gradle 2.2.1 distribution. But this not solved the problem.
I also tried this uninstalled Android Studio 2.3.1 and Install Android Studio 1.1 with Gradle 2.2.1 by default but again the same problem.
The problem could be: import org.codehaus.groovy.tools.StringHelper ???
Finally I solved the problem.
I don't say that all my steps are necessary but this is what I did,
Simply I uninstall all Android Studio and all the Android folders under ..\Users\userName\ and under \Users\userName\AppData\Local\Android.
This to be sure to have a clean installation.
After I install Android Studio 2.3.1 patch to 2.3.3 than downloaded necessary Android API (API 21 in my case).
Then in File-> Settings-> Gradle I checked "Use local Gradle distribution" where mi distribution is gradle-2.2.1
At the end I select Import Gradle Project from the Android Studio Start Menu and no Gradle error message appear and everything seem to be imported correctly.
My opinion is that, the first time I tried to import the project using Gradle 3.2. I suppose some files and folder was generated not correctly, so when I tried to use the correct Gradle version the import not work properly.
When I delete everything and used the correct Gradle version the import was successful.
Thanks to all the people that answer to my question, and tried to help me.
Best Regards
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