your programing

Android Studio Gradle DSL 메서드를 찾을 수 없음 : 'android ()'— 오류 (17,0)

lovepro 2020. 10. 7. 08:01
반응형

Android Studio Gradle DSL 메서드를 찾을 수 없음 : 'android ()'— 오류 (17,0)


Android Studio에서 내 프로젝트를 실행하려고하는데 아래 오류가 나타납니다.

여기에 이미지 설명 입력

나는 이것을 실행하기 위해 많은 출처를 따랐고 여기에 상처를 입혔지만 다른 무엇을 해야할지 모르겠습니다.

이 프로젝트를 실행하도록 구성하려면 어떻게해야합니까?

build.gradle :

    // Top-level build file where you can add configuration options common to all sub-projects/modules.
    buildscript {
        repositories {
            mavenCentral()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:0.9.+'
        }
    }

    allprojects {
        repositories {
            mavenCentral()
        }
    }

    android {
        compileSdkVersion 19
        buildToolsVersion "19.1" 
    }

settings.gradle :

include ':app'

local.properties :

sdk.dir=C\:\\Users\\KJA\\AppData\\Local\\Android\\sdk

gradle.propertes :

# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true

계속해서 제공 한 링크에서 프로젝트를 다운로드했습니다. http://javapapers.com/android/android-chat-bubble/

이것은 오래된 튜토리얼이므로 소프트웨어, gradle, 안드로이드 빌드 도구 및 플러그인을 업그레이드하기 만하면됩니다.

최신 Gradle 및 Android Studio가 있는지 확인합니다.

build.gradle :

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

app / build.gradle :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 23
        versionCode 1
        versionName '1.0'
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.2.1'
}

그런 다음 gradle을 실행합니다.

gradle installDebug

최상위 레벨 build.gradle에는 코드가있는 것 같습니다.

android {
   compileSdkVersion 19
   buildToolsVersion "19.1" 
}

build.gradleAndroid 빌드 플러그인이 아직로드되지 않았기 때문에 최상위 수준에서이 코드를 가질 수 없습니다 . 앱 수준에서 컴파일 버전 및 빌드 도구 버전을 정의 할 수 있습니다 build.gradle.


알 수없는 이유로 Android Studio는 최상위 build.gradle 파일에 android () 메서드를 잘못 추가합니다.

방법을 삭제하면 나를 위해 작동합니다.

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'
}

아래 단계를 통해이 문제를 관리하려고했습니다.

android { ... }최상위 루트 gradle 파일에서 블록 삭제

들여다보다

 compileSdkVersion 22
 buildToolsVersion "22.0.0"

여기서 app / gradle 파일의 코드 줄은 아래 드롭 다운에있는 버전 중 하나만 있어야합니다. 그렇지 않으면 동일한 다운로드 옵션을 제공합니다.

여기에 이미지 설명 입력


Eclipse NDK 프로젝트를 Android Studio로 가져 오려고 할 때 이와 동일한 오류가 발생했습니다. Android Studio에서 NDK를 지원하려면 새로운 gradle 및 Android 플러그인 (및 Gradle 버전 2.5 이상)을 사용해야합니다. 이 플러그인은 모듈의 build.gradle 파일을 변경해야합니다. 특히 " android {...}"개체는 다음 과 같이 " model {...}"개체 내에 있어야합니다 .

apply plugin: 'com.android.model.application'
model {
    android {
    ....
    }
}

따라서 새 gradle 플러그인 및 새 android 플러그인을 사용하도록 gradle 구성을 업데이트했지만 모듈의 build.gradle 구문을 변경하지 않은 경우 "Gradle DSL method not found : 'android ()'"오류가 발생할 수 있습니다. .

주석에 몇 가지 추가 설명이있는 패치 파일을 준비했습니다. https://gist.github.com/shumoapp/91d815de6e01f5921d1f 네이티브 오디오 ndk 프로젝트를 Android Studio로 가져온 후 수행해야하는 변경 사항입니다.


gradle 설정을 수정하는 것은 매우 어렵습니다. Gradle에 대해 잘 모르면 많이 배워야합니다. 대신 다음을 수행 할 수 있습니다.

1) Start a new project in a new folder. Choose the same settings with your project with gradle problem but keep it simple: Choose an empty main activity. 2) Delete all the files in ...\NewProjectName\app\src\main folder 3) Copy all the files in ...\ProjectWithGradleProblem\app\src\main folder to ...\NewProjectName\app\src\main folder. 4) If you are using the Test project (\ProjectWithGradleProblem\app\src\AndroidTest) you can do the same for that too.

this method works fine if your Gradle installation is healthy. If you just installed Android studio and did not modify it, the Gradle installation should be fine.


Actually i tried many combinations nothing worked

but when i modified my application gradle file with following

 buildTypes {
        release {
            minifyEnabled false
        }
    }

By removing the Line

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

it worked Normally :)) cheers


Another solution if you have installed android-studio-bundle-143.2915827-windows and gradle2.14

You can verify in C:\Program Files\Android\Android Studio\gradle if you have gradle-2.14.

Then you must go to C:\Users\\AndroidStudioProjects\android_app\

And in this build.gradle you put this code:

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}

Then, go to C:\Users\Raul\AndroidStudioProjects\android_app\Desnutricion_infantil\app

And in this build.gradle you put:

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '24.0.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
}
dependencies {
compile 'com.android.support:appcompat-v7:23.3.0'
}

You must check your sdk version and the buildTools. compileSdkVersion 23 buildToolsVersion '24.0.0'

Save all changes and restart AndroidStudio and all should be fine !


Just delete these lines from the root build.gradle

android {
compileSdkVersion 19
buildToolsVersion '19.1' }

Now trying and compile again. It should work.


Change to root build.gradle file

to

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

나를 위해 일한 것은 "파일-> 새로 만들기-> 버전 제어에서 프로젝트"로 프로젝트를 가져온 다음 온라인 소스 (예 : GitHub)를 선택하는 것이 었습니다. 이렇게하면 가져 오기에서 모든 .gradle 파일이 생성됩니다.


나는 또한 그 문제를 만나고 단지 하단 코드를 삭제합니다.

DELETE THESE LINES:
android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
}

작동했습니다。


이 오류는 Github에서 프로젝트를 가져올 때 발생했습니다. 이것은 프로젝트가 이전 버전이기 때문에 발생합니다. 루트 gradle에서 아래 방법을 삭제하십시오.

android {compileSdkVersion 19 buildToolsVersion "19.1"}

그런 다음 다시 시도하십시오.

나는 그것이 효과가 있기를 바랍니다.

참고 URL : https://stackoverflow.com/questions/27735646/android-studio-gradle-dsl-method-not-found-android-error17-0

반응형