What's the use of classpath in Gradle buildscript - android

What is the use of including classpath in dependencies section of buildscript build.gradle(Project). Example :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
classpath 'com.android.tools.build:gradle:1.5.0' what is its purpose / what does it do?

This is the classpath used by Gradle itself. If you want to extend your build logic with non-standard plugins or other supporting classes they must be found in this classpath.
The mentioned dependency com.android.tools.build:gradle:1.5.0 contains the plugin doing the android specific build stuff.

Related

android studio clear .gradle on C:\Users\Administrator,can't find one of the classpath

The ERROR:
my app gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.1.8'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
i am sry for that the code can't post,so what i said this sentence is nonsense
Well if you open the url mentioned you will find that this version 1.1.8 does not exist in jcenter repository. The available versions there are:
https://jcenter.bintray.com/com/tencent/mm/AndResGuard-gradle-plugin/
1.2.3/
1.2.4/
1.2.5-RC1/
1.2.5/
1.2.6/
1.2.7/
So either upgrade your AndResGuard-gradle-plugin to a 1.2.x version or change the jcenter repository in by adding maven { url 'https://dl.bintray.com/simsun/maven' }:
buildscript {
repositories {
jcenter()
maven { url 'https://dl.bintray.com/simsun/maven' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.tencent.mm:AndResGuard-gradle-plugin:1.1.8'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.1'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

Error:Failed to complete Gradle execution. Cause: unknown

I am not able to build my project since I get this error image
I tried every solution I could find but I had no luck. I'm using AS 2.1.3. This are my depencies:
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
This morning I was able to work without problems, the only thing I did was some changes in an AsyncTask.
I solved it by deleting the .gradle folder in C:\Users\MyUsername.
The problem is not in the network You just have to add
buildscript {
repositories {
jcenter()
}
dependencies {
// the latest version of the android-apt plugin
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
for apply plugin: 'com.neenbedankt.android-apt' this library .Hope this will help source

Error:Could not find com.android.tools.build:gradle:2.1.0-alpha1

I update my android studio and restart it, it works properly but when i try to imoprt my previous project it shows error somthing like that:
here is the snapshot of error...
Error during import the project
and here is my gradle 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.1.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
}
Try with other distribution of gradle.
Open gradle-wrapper.propertieswhich It's inside gradle/wrapper folder and in distributionUrl set another one which work, for example:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
EDIT
Try with this classpath in global build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
I had the same problem upgrading my Android Studio to 2.2.0. I changed the classpath property of my build.gradle file but the difference with the answers above is that I didn't put the version of the Gradle but the Android Studio's one and it worked. Note that you also need to verify the Ggradle home path in file>>settings>>build,execution,deployment>>gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
// 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
I had this problem today, and when I updated the Android Plugin Version to the recent one, it worked. So, I think when you meet this problem, you can update the Gradle and Android Plugin Version to the newest. It always works. This is my configuration:

Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found

I use the following library to add material design to my android project
https://github.com/navasmdc/MaterialDesignLibrary
But after importing it as a module, I get the following error.
How can I fix it
Error:(2, 0) Plugin with id 'com.github.dcendents.android-maven' not found.
First of all you can use this library as dependency simply adding to your module/build.gradle this dependency:
dependencies {
compile 'com.github.navasmdc:MaterialDesign:1.5#aar'
}
If you want to import locally as module, you have to add this part in your module/build.gradle: (this part is added in the top-level file in the library)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.+'
classpath 'org.codehaus.groovy:groovy-backports-compat23:2.3.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath 'com.github.dcendents:android-maven-plugin:1.2'
}
}
Pay attention that this library is not updated with the last support libraries, and doesn't use the new design support library.
Add these lines in project.gradle dependencies:
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
If you add:
classpath 'com.github.dcendents:android-maven-plugin:1.2'
it does not work some times, so add:
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
To complete, add the following lines into importing module's build.gradle file.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
}
}
enjoy coding.
Import the #arr file in module dependency

Android studio Gradle project scope dependency

I have multiple modules and every module uses exact same dependency. Because it is annoying to maintain that dependency in all build.gradle files (version updates etc.) I'd like to have it in project build.gradle. Is that possible please?
I tried to:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
compile 'joda-time:joda-time:2.8.1'
}
}
allprojects {
repositories {
jcenter()
}
}
but that doesn't work as it seems that gradle is not able to find DSL for compile. Is there any other way please?
Thank you
It's called centralize the support libraries dependencies in gradle. Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.
http://gmariotti.blogspot.in/2015/07/how-to-centralize-support-libraries.html
Correct me if i'm wrong but what's inside buildscript are dependencies for build.
When I generate my project build.gradle there is note :
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
So no, you can't put dependencies for all your module here but maybe there is a plugin for that.
You cannot centralize the dependencies for all (sub-)projects, but is is very easy to centralize the version numbers. In build.gradle in the root add this:
ext {
jodaTimeVersion = '2.8.1'
}
And in build.gradle of the modules that need Joda-Time add this (pay attention to the double quotes):
dependencies {
compile "joda-time:joda-time:${jodaTimeVersion}"
}

Categories

Resources