Gradle DSL 메서드를 찾을 수 없음 : 'compile ()'
이 gradle 오류가 발생했습니다.
오류 : (9, 0) Gradle DSL 메서드를 찾을 수 없음 : 'compile ()'
비슷한 질문을 참조하려고했지만 작동하지 않았습니다.
Android gradle 빌드 오류 : (9, 0) Gradle DSL 메서드를 찾을 수 없음 : 'compile ()'.
Build.Gradle을 동기화 할 때 "Gradle DSL 메서드를 찾을 수 없음 : 'compile ()'"오류가 발생합니다.
지원되지 않는 Gradle DSL 메서드가 발견되었습니다 : 'compile ()'!
내 build.gradle
코드는 여기
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:6.5.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle(Module.app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
defaultConfig {
applicationId "com.example.simplemaker.pushtest"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
내 코드에 어떤 문제가 있습니까?
제 영어 죄송합니다.
감사합니다!
프로젝트 build.gradle
파일 의 메모에서 알 수 있듯이 :
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
해당 gradle 파일에서 2 개의 컴파일 문을 제거합니다.
compile 'com.android.support:appcompat-v7:20.+'
compile 'com.google.android.gms:play-services:6.5.+'
그런 다음 다른 (모듈) build.gradle
종속성을 다음과 같이 만드십시오 .
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.+'
}
I am using Android studio based on IntelliJ Idea and I have changed Settings on when and how to wrap code. Also I had 'reformat automatically' options which lead to formatting Gradle files randomly. So it lead to something like this:
compile 'de.greenrobot:eventbus:2.4.0' compile 'com.jakewharton:butterknife:7.0.1'
Gradle then fails to find compile() for the second compile. As you only allowed to write one dependency per line.
Its really silly problem and I got solution:
as compile statements goes in one line
compile "com.squareup.okhttp3:okhttp:$okHttpVersion" compile "com.squareup.okhttp3:okhttp-urlconnection:$okHttpVersion" compile "com.squareup.okhttp3:logging-interceptor:$okHttpVersion" compile "com.google.code.gson:gson:$gsonVersion"
I just changed next by next line and solved my problem:
compile "com.squareup.okhttp3:okhttp:$okHttpVersion"
compile "com.squareup.okhttp3:okhttp-urlconnection:$okHttpVersion"
compile "com.squareup.okhttp3:logging-interceptor:$okHttpVersion"
compile "com.google.code.gson:gson:$gsonVersion"
Hope it will helps you. Thank you.
Check your build.gradle files, sometimes when you add a module to your current module using the project settings, the build.gradle of current module is corrupted, and indents are broken, just check current build.gradle and check if all the compile statements are issued in a new line!
in addition to proper replies already given above - a picture for more detailed explanation:
Project has 2 build.gradle. You need the highlighted one: build.gradle (Module: app)
Check your project. there is 2 build.gradle.
Move your compile line to another build.gradle
Application dependencies must include in app -> build.gradle file. Not in Project -> build.gradle file.
A simple mistake can cause this problem too, don't include classpath
dependencies to build.gradle(Module:app)
In my case, I was getting this error because I had a dependency implementation line outside the dependencies
block. Something like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
...
}
implementation 'androidx.media:media:1.1.0'
Note that all implementation calls must be defined within the dependencies block. That's the simple fix.
I hope this helps someone out there.
Merry coding!
참고URL : https://stackoverflow.com/questions/27617687/gradle-dsl-method-not-found-compile
'code' 카테고리의 다른 글
PHP read_exif_data 및 방향 조정 (0) | 2020.10.18 |
---|---|
Java에서 while 루프를 어떻게 종료합니까? (0) | 2020.10.18 |
Apache Tomcat 서버의 명령 프롬프트에서 디버그 모드를 시작하는 방법은 무엇입니까? (0) | 2020.10.18 |
CSS를 사용하여 텍스트를 감싸는 방법은 무엇입니까? (0) | 2020.10.18 |
비트 맵 크기 조정 / 크기 조정 후 이미지 품질이 좋지 않습니다. (0) | 2020.10.18 |