When i open my gradle project in Android Studio, it will show build successful in the terminal while after that it shows the following error:
Could not execute build using Gradle distribution
'http://services.gradle.org/distributions/gradle-1.6-bin.zip'. Task 'wrapper' not found in root project 'gradle'.
Althoug I am running gradle 1.9, I dont know why this error is shown
If you are using gradle wrapper make sure these lines are added in to your top level build.gradle file
task wrapper(type: Wrapper) {
gradleVersion = '1.9'
}
Also your $YOUR_PROJECT_DIR/gradle/gradle-wrapper.properties should point to write distribution url, I have observed that distrinutionUrl defined in gradle-wrapper.properties file changes aumatically according to the gradle version defined in wrapper task while syncing. If the task is not defined by default it changes to 1.6 .
So check it and make it correct
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-bin.zip
And finally wherever you have defined your gradle dependencies class-path in build.gradle files they all should be
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
0.7.* is used for gradle version 1.9 , you can make all the changes as per your gradle version.
Related
Previously, I was using
classpath 'com.android.tools.build:gradle:3.0.1'
and everything was working fine.
After upgrading to
classpath 'com.android.tools.build:gradle:3.2.1'
however, I see the following issue. after build the project using the command
./gradlew assembleDebug
After build success, I can not find classes or app_classes in app/build/intermediates but I need source classes files.
why it happend?
Make sure you are using gradle 4.6 add this to your build.gradle file
distributionUrl = https\://services.gradle.org/distributions/gradle-4.6-all.zip
as for 3.2+ you will need gradle 4.6 atleast, check documentation here.
https://developer.android.com/studio/releases/gradle-plugin
If your build is from debug and you have not build using build -> build apk then you can find the required classes in below path.
build\intermediates\javac\debug\compileDebugJavaWithJavac
Foreword: I know that there are dozens of questions about the error I'm getting but still I don't think my question is a duplicate because it seems all older questions refer to building using Android Studio whereas I'm trying to build an Android app from the command line on Windows.
So here we go: I've just installed the latest Android Studio, Android NDK and JDK 8 on a Windows 7 system. I've created a minimal test project with a build.gradle which looks like this:
// 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.3.1'
// 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
}
When I open a command line and type gradle wrapper I get the following error:
Build file 'D:\TestProject\app\build.gradle' line: 1
* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin [id 'com.android.application']
> Minimum supported Gradle version is 3.3. Current version is 3.2. If using the gradle wrapper, try editing the distributionUrl in D:\TestProject\gradle\wrapper\gradle-wrapper.properties to gradle-3.3-all.zip
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 1.085 secs
I cannot follow the advice presented in the error message because the file D:\TestProject\gradle\wrapper\gradle-wrapper.properties simply doesn't exist yet. AFAIU, this stuff is part of the wrapper and should be generated by a call to gradle wrapper so prompting me to modify a file which doesn't exist doesn't make too much sense to me.
What is even more confusing is the fact that when I open the HelloJNI test project provided by Google in Android Studio and go to File/Project Structure/Project the Gradle version is shown as 3.3. However, looking inside C:\Program Files\Android\Android Studio\gradle shows that I only have 3.2 installed, not 3.3, because there is only a gradle-3.2 directory inside C:\Program Files\Android\Android Studio\gradle.
So this is all rather confusing and I'm out of ideas about how to fix this. That's why any help is greatly appreciated!
When I open a command line and type gradle wrapper I get the following error
The fact that this actually runs means that you installed a standalone local copy of Gradle. You are not running the Gradle Wrapper yet, as that would be ./gradlew, not gradle.
So, visit the Gradle installation site and upgrade your standalone local copy of Gradle to 3.3.
In your top build.gradle file, add the following:
task wrapper(type: Wrapper) {
gradleVersion = "3.5"
}
Then run the command:
gradlew wrapper
After this is done, you should be able to re-sync with the IDE.
I have been struggling with this gradle for the last one week. None of the earlier questions on gradle issue could solve my problem.
Things I did :
Download the latest gradle. I did it by changing the path at distribution URL in gradle-wrappper properties.
(It will download the latest one say 2.14. but, When I create a new project, It will be set to 2.10 and then back to same dirt)
Should I download the gradle for every project I create ? ... Help me fix this.
Thanks in advance :)
This is the error when I create a new project
Use the latest version of gradle with in build.gradle.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
Don't confuse gradle and the android plugin for gradle.
1) You can define the gradle distribution used by a project in the file
gradle/wrapper/gradle-wrapper.properties
For example:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.14-all.zip
Each project can use a different version. You will find the distributions file inside \user\.gradle\wrapper\dists folder.
2) Gradle is a build tool, but it requires specific plugin to work.
Android Tool Team is releasing the Android plugin for Gradle.
You can define the plugin inside the build.gradle file in the project.
For example:
classpath 'com.android.tools.build:gradle:2.1.3'
Each project (or module) can use a different version.
Also go to File > Settings > Builds,Execution,Deployment > Build Tools > Gradle
and set Use default gradle wrapper
I've made some waste code. After some mistakes I checkout latest commit. I expected to restart with any without any hitch. But building project now I receive the message:
Waiting for device.
Target device: samsung-gt_i8190n-47900693715f5036
Uploading file
local path: /Path/to/file.apk
remote path: /path/to/file/com.example
Local path doesn't exist.
(* I've removed complete local and remote path in this post ...)
Thus, when I try to sync project with gradle files, a new message from editor arrives:
Failed to refresh Gradle project 'NutriMondoProject'
Project is using an old version of the Android Gradle plug-in.
The minimum supported version is 0.7.0.
Please update the version of the dependency 'com.android.tools.build:gradle'
in your build.gradle files.
Search in build.gradle files
I feel like a fish out of water.
You have updated to Android Studio 0.4.0
it requires gradle plugin 0.7.+ and gradle-wrapper 1.9.
Change your build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
Then change your gradle-wrapper.properties:
distributionUrl=http\://services.gradle.org/distributions/gradle-1.9-all.zip
Then sync your project with gradle files.
Launch gradlew clean to clean your build.
It's because you updated your Android Studio to version 0.4.0.
Follow those steps to make it work :
http://tools.android.com/recent/androidstudio040released
I'm trying to create a simple android project with gradle. I work in a computer with Debian GNU/Linux 7 'wheezy'.
I followed the recomendations in Gradle Plugin User Guide - Android Tools Project Site, but it casts an error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/alex/Proyectos/MyLogin/build.gradle' line: 11
* What went wrong:
A problem occurred evaluating root project 'MyLogin'.
> Could not create plugin of type 'AppPlugin'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.817 secs
I followed the specifications:
Gradle 1.9
Plugin 0.7
SDK 17+ (actually 19)
I also started a project anew, and the results I showed were issued by the command gradle tasks as shown in the documentation.
I also tried gradle 1.10, but the result is the same.
Even this question was not usefull, since it solved with 'upgrading' to gradle 1.6 (I understand that plugin 0.7 requires at least gradle 1.9).
I tried this after failing with the same error in android-studio and IntelliJ Idea.
EDIT: I also tried with new projects in both IDEs, and got the same issue. But what most surprises me is that both IDEs use gradle 1.8 in their wrapped form. I tried to cinfigure both of them to use my local gradle install, but still the same issue.
What am I doing wrong? Is it a bug? How can I avoid the problem?
Please, help me.
EDIT: Here is my build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 14
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
sourceCompatibility = 1.6
version = '0.1'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
//compile project(':core')
}
Google made a mistake with version 0.7.2 of the Gradle plugin:
Note: 0.7.2 requires Java7. This is a mistake. Use 0.7.3 instead.
Release 0.7.3 re-enables Java6 support. Declaring Gradle 0.7.3 in my build files does indeed resolve this for me.
No one is perfect :)
http://tools.android.com/tech-docs/new-build-system
Use Gradle 1.9 instead of Gradle 1.10. There is an issue with 1.10 : https://code.google.com/p/android/issues/detail?id=63822
Also answered here:
Can't find org.gradle.api.artifacts.result.ResolvedModuleVersionResult when apply Android plugin in Gradle
I got it working using Gradle 1.10 with the Gradle plugin 0.8.0.
// /build.gradle
// Top-level build file where you can add configuration
// options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
...
# /gradle/wrapper/gradle-wrapper.properties.
#Sat Feb 01 20:41:29 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
If you're using the command line to create the project like so:
android create project -g -v 1.2.2 --target 1 --name rtest --path rtest --activity MainActivity --package com.mydomain.rtest
The project is created to use version 1.2.2 of the android-gradle-plugin, but the project is initialised with gradle 1.12, which isn't compatible.
To fix it, do the following:
Open rtest/gradle/wrapper/gradle-wrapper.properties and set distributionUrl to the release you want; for example: http\://services.gradle.org/distributions/gradle-2.2.1-all.zip (don't forget to escape the colon - yes, that makes me smile too);
Open build.gradle and change runProguard false to minifyEnabled false;
./gradlew clean && ./gradlew assembleDebug
I also remove the hidden .gradle folder, but I'm not sure if it's necessary
And it all works again.
For those who are using 2.1 version of studio, replace classpath 'com.android.tools.build:gradle:2.1.0-rc1' with classpath 'com.android.tools.build:gradle:2.1.0'. This solved my problem.
If you are attempting to update your Gradle 1.9 project to Gradle 1.10 using
task wrapper(type: Wrapper) {
gradleVersion = '1.10'
}
and command ./gradlew wrapper you will get the same error as above.
Solution is to install Gradle 1.10 onto your machine and upgrade your project not using the wrapper
gradle wrapper
You can also get this error if you update your system gradle and forget to update the Android Studio gradle home.
I got this today when running gradle assembleRelease. I had installed the Ubuntu default of gradle-1.4. This didn't work, so I tried the latest gradle-1.12 and got the same issue.
Downloading and using gradle-1.10 (and matching my gradle-wrapper.properties file to that version) resolved the issue.
This is with Android Studio 0.5.8.
Go to dependencies and just change the dependencies classpath to
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
Rest Gradle will take care. Happy coding :)
Ok i guess android studio has answer for this to get this bug out using GUI,
I had this error like this...
after updating the plugins i was facing another issues while building,
so changes the gradle setting to default as shown in the image,
After this build was successful.