code

Android gradle 빌드 오류 : (9, 0) Gradle DSL 메서드를 찾을 수 없음 : 'compile ()'.

codestyles 2020. 12. 12. 10:54
반응형

Android gradle 빌드 오류 : (9, 0) Gradle DSL 메서드를 찾을 수 없음 : 'compile ()'.


프로젝트를 동기화하려고 할 때 다음 빌드 오류가 발생합니다.

Error:(9, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'AlexTest' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin.
link: Apply Gradle plugin

나는 그들이 나를 연결하는 모든 단일 gradle 플러그인을 하단의 해당 링크에 적용하려고 시도했지만 동일한 문제이므로 첫 번째 오류가 원인이라고 결론지었습니다.

다음은 AlexTest 용 build.gradle 파일 (프로젝트 디렉토리)입니다.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.13.2'
        compile 'com.google.android.gms:play-services:6.1.11'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

나는 그것이 문제가 있었던 gradle 파일이라고 생각합니다. 하지만 어떤 방법을 말하는지 잘 모르겠습니다.

또한 여기에 언급 된 gradle-wrapper.properties도 있습니다.

#Mon Nov 10 01:06:12 PST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip

아마도 distributionUrl의 gradle 버전이 종속성의 버전과 일치해야합니까?

나는 또한 app 디렉토리 자체에 build.gradle 파일이 있습니다-1 수준 더 낮지 만 그것이 참조하는 것이라고 생각하지는 않지만 여기에 있습니다.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.snappiesticker.alextest"
        minSdkVersion 16
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:6.1.+'
}

나는 그들이 나를 연결하는 모든 단일 gradle 플러그인을 하단의 해당 링크에 적용하려고 시도했지만 동일한 문제이므로 첫 번째 오류가 원인이라고 결론지었습니다.

옳은.

다음은 AlexTest 용 build.gradle 파일 (프로젝트 디렉토리)입니다.

You will notice that this file contains a code comment:

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files

Remove the compile 'com.google.android.gms:play-services:6.1.11' line from that file. Leave the compile 'com.google.android.gms:play-services:6.1.+' that you have in the other build.gradle file.

The dependencies closure in buildscript is for Gradle plugins only. The top-level dependencies closure, found in the module's build.gradle file, is for application dependencies.


Saw reports that the problem occurred for other reasons, but this solved for me.

If you carry out any changes in the Project Structure (Android Studio) and press OK, Gradle will be synchronized, but this type of synchronization, if the dependency block has something like:

This block will stay this way after synchronization:

One way to solve the problem is to insert a line break to stay as it was before the synchronization or put a semi-colon between the two statements.

I hope it helps.


Just add foolwoing statement in your dependencies

apply plugin: 'jetty'


Hi everyone for me it was a "couple days consuming job" to make my app run in Android Studio (I migrated from Eclipse and had this problem too ) . Finally I found that very simple way of it .

  1. Create libs folder under src/main/java/ it is App/java/libs in left pane .
  2. Copy and paste all your external jars into here.
  3. Goto left pane and right click on your App then click Open Module Settings
  4. Then Project Structure window will appear .
  5. Then move to Dependencies tab . Final Step : Add all your jars located in App/java/libs (You will find them in src/main/java/libs) one by one .

That is all Enjoy it.


Declare dependencies in Module's build.gradle file, not in AlexTest's build.gradle file

enter image description here

참고URL : https://stackoverflow.com/questions/26851230/android-gradle-build-error9-0-gradle-dsl-method-not-found-compile

반응형