'MyProject'루트 프로젝트에서 찾을 수없는 'Task'와 함께 Android Studio 빌드가 실패합니다.
랩톱을 변경하고 Android Studio 버전 0.8.2로 업데이트 한 후 프로젝트를 빌드하려고하면이 오류가 발생합니다.
실패 : 예외로 인해 빌드가 실패했습니다.
문제 : 루트 프로젝트 'MyProject'에서 작업 ''을 (를) 찾을 수 없습니다.
시도 : 사용 가능한 작업 목록을 가져 오려면 gradle 작업을 실행하십시오. --stacktrace 옵션으로 실행하여 스택 추적을 가져옵니다. 더 많은 로그 출력을 얻으려면 --info 또는 --debug 옵션과 함께 실행하십시오.
빌드 실패
내 Gradle 파일은 다음과 같습니다.
최상위 설정 .gradle
include ':MyProject'
MyProject의 build.gradle :
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:0.12.+"
}
}
repositories {
mavenCentral()
}
android {
compileSdkVersion 20
buildToolsVersion "20"
defaultConfig {
minSdkVersion 14
targetSdkVersion 20
}
}
dependencies {
compile 'de.timroes.android:EnhancedListView:0.3.0@aar'
compile 'com.nineoldandroids:library:2.4.0'
}
최상위 build.gradle이 비어 있습니다.
답변은 늦었지만 Google (작은 따옴표)에게는 어려운 일이며 무슨 일이 일어나고 있는지 명확하지 않습니다. 아직 댓글을 달거나 범위를 요청 (또는 링크 3 개 게시) 할 평판이 없기 때문에이 답변은 약간 지루할 수 있습니다.
빠른 답변을 위해 프로젝트에 여러 Gradle 플러그인이있을 수 있습니다.
Gradle 래퍼 및 플러그인 동기화
내 문제는 손상된 IML 파일로 시작하는 것 같습니다. Android Studio (프로젝트 닫기와 다시 열기 사이)는 IML이 없어졌고 (아닙니다) 모듈을 삭제해야한다고 불평하기 시작했습니다. 계속해서 AS 0.8.7 (카나리아 채널)로 업그레이드하고 OP 문제 (루트 프로젝트에서 찾을 수없는 태스크 '')에 갇혀있었습니다. 이것은 빌드를 완전히 차단했기 때문에 Gradle을 파헤쳐 야했습니다.
OSX에서의 수리 단계 (Windows에 맞게 조정하십시오) :
- Android Studio를 0.8.7로 업그레이드
- 환경 설정 | 업데이트 | "Beta Channel"을 "Canary Channel"로 전환 한 다음 지금 확인을 수행합니다.
- 이것을 건너 뛸 수 있습니다.
Gradle 래퍼를 확인했습니다 (현재 1.12.2, 현재 2.0을 사용하지 마십시오).
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 be set in Android Studio at Preferences | Gradle (but 0.8.7 was giving me ‘invalid location’ errors).
- The 'wrapper' is just a copy of Gradle for each Android Studio project. It allows you to have Gradle 2 in your OS, and different versions in your projects. The Android Developer docs explain that here.
- Then adjust your build.gradle files for the plugin. The Gradle plugin version must be 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 will throw an error with the acceptable range for the wrapper.
Example, in build.gradle, you have 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 you’re changing from in each case) verifying that every build.gradle file in your project 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 library (originally gradle:0.8.+) and my main project (originally 0.12.+) to the fixed version: gradle:0.12.2.
Other checks
Ensure you don’t have two Android Application modules in the same Project
This may 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 pop up a window asking what application you want to make.
- Invalidate your caches
- File | Invalidate Caches / Restart (stackoverflow.com/a/19223269/513413)
- 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.
- 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 two Gradle plugins in my project. So I think the Gradle plugins fought each other; one crashed, the other lost its state and reported the error.
If you have time, the 1-hour video "A Gentle Introduction to Gradle" (www.youtube.com/watch?v=OFUEb7pLLXw) really helped me 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 pressure. In the last few months I have hit every wall I think Android has; I've been here quite often and this is my first post. I thought this was a hard fix, so I sincerely apologize if the quality of my answer reflects the difficulty I had in getting to it.
Download system image(of targeted android level of your project) from sdk manager for the project you have imported.
This error comes when you do not have target sdk of your android project installed in sdk folder
for eg. Your imported project's target sdk level may be android-19 and on sdk folder->system-images you may have android-21 installed. so you have to download android-19 system image and other files from sdk manager or you can copy paste it if you have the system image.
Remove:
<facet type="android" name="Android">
<configuration />
</facet>
in your iml file. That works for me.
https://plus.google.com/+AlexRuiz/posts/49hP3V9GSGe
This happened to me recently when I close one Android Studio project and imported another Eclipse project. It seemed to be some bug in Android Studio where it preserves some gradle settings from previously open project and then get confused in the new project.
The solution was extremely simple: Close the project and shut down Android Studio completely, before re-opening it and then import/open the new project. Everything goes smoothly from then on.
Simple fix for me was
- Build > Clean project
- Restart Android Studio
In my case, setting the 'Gradle version' same as the 'Android Plugin version' under File->Project Structure->Project fixed the issue for me.
Apparently this error has multiple causes. Here's what fixed it for me.
I was running the build command like this:
./gradlew :testapp: build
Running it without the space fixed the issue:
./gradlew :testapp:build
I got this error when switching from one Git branch to another, and then trying to run "Clean Project". I used ack
to search for the Task name, and found it in a .iml file.
My solution was to regenerate the project's .iml file by clicking (in the main menu) Tools > Android > Sync Project with Gradle Files. (Thanks to this answer.)
Sometimes, if you have opened two windows of Android Studio, and when you try to compile, this issue might happen. For me, when I was compiling a backed Google Cloud Endpoint module which was not embedded in a project, rather shared among different Android Studio projects, and when there is more than once instance open, this error use to spring up for me. But as soon as you close other windows, everything will be fine. Sometimes, you might have to restart Android Studio altogether.
Make sure you have the latest values in your gradle files. As of this writing:
buildToolsVersion "21.1.2"
dependencies { classpath 'com.android.tools.build:gradle:1.1.0' }
Yet another solution to the same problem:
This happened to me every time I imported an eclipse project into studio using the wizard (studio version 1.3.2).
What I found, quite by chance, was that quitting out of Android studio and then restarting studio again made the problem go away.
Frustrating, but hope this helps someone...
- Open Command Prompt
- then go your project folder thru Command prompt
- Type gradlew build and run
Problem
I specifically got the "[module_name]:prepareDebugUnitTestDependencies" task not found
error, every time I ran gradle build. This happened to me after updating my Android Studio to 3.0.0.
Investigation
I had previously added command-line options to the gradle-based compiler, which you can find under: File -> Settings -> Build, Execution, Deployment -> Compiler -> Command-line Options. Specifically, I had excluded a number of tasks, including the aforementioned task. While that worked fine on the previous stable version (2.3 at that time), it seems like this was the reason behind the build failure.
Solution
This is one of many possible solutions. Make sure you have the correct command-line options specified in the settings under: File -> Settings -> Build, Execution, Deployment -> Compiler -> Command-line Options, and that none of them is causing this problem.
In my case, I removed the exclusion of this task (and other tasks that seemed related), left the unrelated tasks excluded, and it worked!
Set the path of the root folder and after run the below command
ex : cd C:\Users\maha\Documents\gradle\gs-gradle-master\initial
This is what I did
Remove .idea folder
$ mv .idea .idea.bak
Import the project again
I remove/Rename .gradle
folder in c:\users\Myuser\.gradle
and restart Android Studio and worked for me
Apparently this issue caused by Android Studio on the various situation but the reason is build error When importing an existing project into android studio.
In my case, I've imported my exist project where I was supposed to install few build tools then finally build configuration was done with error. In this case, just do the following things
- Close the current project
- File>New>Import Project (Don't use the open recent project)
Note: I'm sure this kind of error is not on source code when this happened on Import project.
I got this problem because it could not find the Android SDK path. I was missing a local.properties
file with it or an ANDROID_HOME
environment variable with it.
'IT story' 카테고리의 다른 글
버퍼 비우기 란 무엇을 의미합니까? (0) | 2020.09.16 |
---|---|
PowerShell`profile.ps1` 파일에는 무엇이 있습니까? (0) | 2020.09.16 |
1 바이트! = 8 비트? (0) | 2020.09.16 |
원격 서버 hg 경로를 얻는 방법은 무엇입니까? (0) | 2020.09.16 |
Github 페이지가 업데이트되지 않습니다. (0) | 2020.09.16 |