33

My current project had been building with Gradle just fine, since I created it (about a month ago), after acquiring Android-Studio. [I installed some earlier updates to Android-Studio, and had no problems with those.]

But, today, after I upgraded Android-Studio's newest update to a "July 11th" build, going from version 0.1.9 to 0.2.0, my project started complaining that Gradle now needs to be at minimum of 0.5.0. (My project was asking for Gradle 0.4, and this new Studio upgrade flagged my Gradle build and stated it would NOW need this new higher minimum of Gradle.

So, what I'm unclear about: I've been assuming Gradle is PART of (bundled with) Android Studio.

Do I now need to get a newer Gradle, as a separate product/update?

I'm confused!!!

EDIT: (This is happening under Windows-7).

David
  • 2,253
  • 5
  • 23
  • 29

7 Answers7

85

Solution for me without reinstalling or creating a new project:

Step 1: Change line in build.gradle from:

dependencies {
    classpath 'com.android.tools.build:gradle:0.4'
}

to

dependencies {
    classpath 'com.android.tools.build:gradle:0.5.+'
}

Note: for newer versions of gradle you may need to change it to 0.6.+ instead.

Step 2: In the <YourProject>.iml file, delete the entire<component name="FacetManager">[...]</component> tag.

Step 3 (Maybe not necessary): In the Android SDK manager, install (if not already installed) Android Support Repository under Extras.


Info found here

lyallcooper
  • 2,606
  • 2
  • 19
  • 18
  • 3
    Only needed step 1 now (version 0.2.9) – hBrent Sep 17 '13 at 23:05
  • In Android Studio 0.2.11 (a) there was no `dependencies...` block in `build.gradle`, (b) My project's .iml file had no FacetManager component, and (c) I already have Android Support Repository installed...at a loss – Spencer Williams Oct 07 '13 at 19:11
  • 1
    Only needed step 1 and a change to gradle-wrapper.properties (changed to 1.9) when updating to 0.4.2. – Tim Scarborough Jan 09 '14 at 12:38
  • Still didn't get it running with the steps u offered with error: _Error:Could not find any version that matches de.richsource.gradle.plugins:gwt-gradle-plugin:0.5+. Required by: :Android:unspecified_ Running Andriod Studio(Beta) 0.8.2. How do i install new versions of Gradle? – Jeroen van Langen Jul 22 '14 at 19:54
  • I wonder why every one is calling it gradle, isnt it the ANDROID PLUGING FOR GRADLE, not the gradle itself ... pls correct me if I m wrong. How do I knwo which version of gradle or android gradle plugin to use with which version of android studio ? Thnx – Tanvir Feb 19 '15 at 08:36
  • 1
    Step 1 doesn't work if you do not have the .jar and .pom files of the version you are upgrading to. – portfoliobuilder Jun 18 '15 at 00:31
  • Can anyone actually explain the *why* of these steps? – WiseOldDuck Jul 19 '16 at 17:52
3

Basically if you follow the issues in this link for 0.2 you'll likely get yourself fixed, I had the same problems with 0.2

Emzor
  • 1,380
  • 17
  • 28
Peter Fox
  • 1,809
  • 2
  • 20
  • 34
2

Gradle should be updated already, you just need to let your previous projects know gradle has been updated.

Source

Edit your build.gradle file to show this:

dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}

This should only be required for projects created with the previous version of Android Studio. New projects you create will have that by default.

RevanthKrishnaKumar V.
  • 1,855
  • 1
  • 21
  • 34
daniel_c05
  • 11,438
  • 17
  • 60
  • 78
  • Yes, that was my understanding, too. However, when I do that, I now get errors during the attempt to build. – David Jul 14 '13 at 14:02
  • 1
    Specifically:Gradle: FAILURE: Could not determine which tasks to execute. * What went wrong: Task 'assemble' not found in root project 'Slims_SchedProject'. * Try: Run gradle tasks to get a list of available tasks. – David Jul 14 '13 at 14:03
  • And even worse, when I try to create a new project, I now get:Failed to import Gradle project: Could not fetch model of type 'IdeaProject' using Gradle distribution – David Jul 14 '13 at 15:58
  • Did you uninstall your previous Android Studio? On the troubleshooting steps its stated that installing over previous version could cause a few problema – daniel_c05 Jul 14 '13 at 16:11
2

Ok, I finally resolved this, by completely de-installing Android-Studio, and then installing the latest (0.2.0) from scratch.

EDIT: I also had to use the Android SDK-Manager, and install the component in the 'Extras' section called the Android Support Repository (as mentioned elsewhere).

Note: This does NOT fix my old existing project...that one still will not build, as indicated above.

But, it DOES solve the issue of now being able to at least create NEW projects going forward, that build ok using 'Gradle'. (So, basically, I re-created my proj from scratch under a new name, and copied all my code and project xml-files, etc, from the old project, into the newly-created one.)

[As an aside: I've got an idea, Google! Why don't you refer to versions of Android-Studio using numbers like 0.1.9 and 0.2.0, but then when users click on 'About' menu item, or search elsewhere for what version they are running, you could baffle them with crap like 'the July 11th build' or aka, some build number with 6 or 8 digits of numbering, and make them wonder what version they actually have! That will keep the developers guessing...really will sort the wheat from the chaff, etc.]

For example, I originally installed a kit named: android-studio-bundle-130.687321-windows.exe

Today, I got the "0.2.0" kit???, and it has a name like: android-studio-bundle-130.737825-windows.exe

Yep, this version #ing system is about as clear as mud.
Why bother with the illusion of version#s, when you don't use them!!!???

David
  • 2,253
  • 5
  • 23
  • 29
1

if you get this error

Gradle: 
FAILURE: Could not determine which tasks to execute.
* What went wrong:
Task 'assemble' not found in root project 'MyProject'.
* Try:
Run gradle tasks to get a list of available tasks.

You need to edit your Projects .iml file. not the one under src. the one that is like myappProject.iml' delete the whole component name = facetmanager

<module external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
...remove this element and everything inside such as <facet> elements...
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
...keep this part...
</component
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
cubeloid
  • 149
  • 1
  • 6
1

now you can use the last 1.0.0-rc1 this way :

classpath 'com.android.tools.build:gradle:1.0.0-rc1'

This needs Gradle 2.0 if you don't have it Android Studio will ask you to download it

Nadir Belhaj
  • 11,953
  • 2
  • 22
  • 21
1

For people who have this problem today(to example to switch from 2.8.0 to 2.10.0), move to file gradle-wrapper.properties and set distributionUrl with the value you need. distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

I changed 2.8.0 to 2.10.0 and dont forget to Sync after

Cedriga
  • 3,860
  • 2
  • 28
  • 21