Android
Gradle: Could not find method leftShift() for arguments on task ':clean' of type org.gradle.api.DefaultTask.
rhys
2019. 11. 10. 12:46
반응형
Could not find method leftShift() for arguments on task ':clean' of type org.gradle.api.DefaultTask.
Could not get unknown property 'clean' for root project 'projectName' of type org.gradle.api.Project
안드로이드 스튜디오 그래들 빌드 중 이런 에러를 뱉으면 gradle wrapper를 잘못 설정한 경우가 대부분.
그땐 gradle-wrapper.properties 파일의 distributionUrl을 수정하면 됨
내 경우 프로젝트가 그래들 4.5.1에 맞춰져 세팅되어 있는데 5.4.1이 잘못 들어가 있어(init.gradle?)
아래처럼 4.5.1로 바꿔주었더니 해결
distributionUrl=https₩://services.gradle.org/distributions/gradle-4.5.1-all.zip
정말 프로젝트 그래들 버전을 올리고자 하는 거라면 위 두 에러는 아래와 같이 처리
task clean << {
def bdir = new File('.build')
if (bdir.exists()) {
bdir.deleteDir()
}
}
이런 오래된 코드가 있을때
Could not find method leftShift() for arguments on task ':clean' of type org.gradle.api.DefaultTask.
<< 연산자에다 Alt+Enter하면 아래와 같이 leftShift()로 대체가 가능하며
task clean.leftShift({
def bdir = new File('.build')
if (bdir.exists()) {
bdir.deleteDir()
}
})
Could not get unknown property 'clean' for root project 'projectName' of type org.gradle.api.Project
build폴더 clean하는 부분은 아래와 같이 대체 가능
task clean(type: Delete) {
delete rootProject.buildDir
}
https://docs.gradle.org/current/userguide/gradle_wrapper.html
The Gradle Wrapper
It is recommended to always execute a build with the Wrapper to ensure a reliable, controlled and standardized execution of the build. Using the Wrapper looks almost exactly like running the build with a Gradle installation. Depending on the operating syst
docs.gradle.org
반응형