Task ' not found in root project ' * * *.

Source: Internet
Author: User

Android compilation app error: Task ' not found in root project ' * * *.
Put the Build.gradle in the

if (gradle.gradleversion >= "2.2") {
dependencies {
Classpath ' com.android.tools.build:gradle:1.0.0+ '
}
} else if (gradle.gradleversion >= "2.1") {
dependencies {
Classpath ' com.android.tools.build:gradle:0.14.0+ '
}
} else {
dependencies {
Classpath ' com.android.tools.build:gradle:0.12.0+ '
}
}

The last 0.12.0+ changed into 0.12.2.
---------------------------Reference-------------------------------------

Though late in answering, this was a hard one to Google (the one quotes) and it's not clear what ' s happening. I don ' t has the reputation yet to comment or ask for scope (or post 3 links) and so this answer is a little tedious.

To answer fast, your may has multiple Gradle plugins in your project.

Synchronize Gradle Wrapper and Plugins

My issue seemed to start with a corrupted IML file. Android Studio (between closing and reopening a project) began complaining an IML is gone (it wasn ' t) and a module should be deleted, which I declined. It persisted, I upgraded to as 0.8.7 (Canary Channel) and got stuck on the OP issue (Task "not found in Root project"). This completely blocked builds so I had to dig in to Gradle.

My repair steps on OS X (please adjust for Windows):

  1. Upgrade Android Studio to 0.8.7
    • Preferences | Updates | Switch "Beta channel" to "Canary channel" and then does a Check now.
    • You might is able to skip this.
  2. Checked the Gradle wrapper (currently 1.12.2; don ' t try to use 2.0 at this time).

    • Assuming you don ' t need a particular version, use the latest supported distribution

      $ vi ~/project/gradle-wrapper.properties ... distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip

    • This can is set in Android Studio at Preferences | Gradle (But 0.8.7 is giving me ' invalid location ' errors).

    • The ' wrapper ' is just a copy of Gradle for each Android Studio project. It allows to the Gradle 2 in your OS, and different versions in your projects. The Android Developer docs explain.
    • Then adjust your build.gradle files for the plugin. The Gradle plugin version must is compatible with the Distribution/wrapper version, for the whole project. As the Tools documentation (TOOLS.ANDROID.COM/TECH-DOCS/NEW-BUILD-SYSTEM/USER-GUIDE#TOC-REQUIREMENTS) is slightly out Of date, you can set the plugin version too low (like 0.8.0) and Android Studio would throw a error with the acceptable RA Nge for the wrapper.

Example, in Build.gradle, you had this plugin:

dependencies {    classpath "com.android.tools.build:gradle:0.12.+"}

You can try switching it to the exact version, like this:

dependencies {    classpath "com.android.tools.build:gradle:0.12.2"}

and (after recording-what version of you ' re changing from the each case) verifying, every Build.gradle file in your Projec T pulls in the same plugin version. Keeping the "+" should work (for 0.12.0, 0.12.1, 0.12.2, etc), but my build succeeded when I updated Google ' s volley Libra Ry (originally gradle:0.8.+) and my main project (originally 0.12.+) to the fixed version:gradle:0.12.2.

Other checks
  1. Ensure you don't have the Android application modules in the same Project

    • This could interact with the final solution (different Gradle versions, above), and cause

      UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define (various classes)

    • To check, Build | Make Project should not pops up a window asking what application you want to make.

  2. Invalidate your Caches
    • File | Invalidate Caches/restart (stackoverflow.com/a/19223269/513413)
  3. If Step 2 doesn ' t work, delete ~/.gradle/(www.wuttech.com/index.php/tag/groovy-lang-closure/)
    • Quit Android Studio
    • $ RM-RF ~/.gradle/
    • Start Android Studio, then sync:
      • Tools | Android | Sync Project with Gradle Files
    • Repeat This entire sequence (Quit...sync) a few times before giving up.
  4. Clean the project
    • Build | Clean Project
If you see this ...

In my recent builds, I kept seeing horrible fails (pages of exceptions) but within seconds the messages would clear, build Succeeded and the app deployed. Since I could never explain it and the app worked, I never noticed that I had II Gradle plugins in my project. So I think the Gradle plugins fought each other; One crashed, the other lost it state and reported the error.

If you had time, the 1-hour video "A Gentle Introduction to Gradle" (www.youtube.com/watch?v=OFUEb7pLLXw) really helped m E approach the Gradle build files, tasks, build decisions, etc.

Disclaimer

I ' m learning this entire stack, on a foreign OS, after working a different career...all at the same time and under Pressur E. The last few months I had hit every wall I think Android had; I ' ve been here quite often and this is my first post. I thought this is a hard fix, so I sincerely apologize if the quality of my answer reflects the difficulty I had in Getti Ng to it.

Task ' not found in root project ' * * *.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.