Wednesday, May 27, 2020

Gradle sync failed: Gradle DSL method not found: 'android ()'

Gradle sync failed: Gradle DSL method not found: 'android ()'

What should i do to fix this issue? I am getting this error when i ever i run my project in android studio0.9.1
android {compileSdkVersion 17
buildToolsVersion "19.1.0"
defaultConfig {
    applicationId "com.example.nearby"
    minSdkVersion 11
    targetSdkVersion 19
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}}dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:19.0.0'
compile files('libs/google-play-services.jar')}

Answers Gradle DSL method not found: 'android ()'

I just ran into this same error. Make sure you don't have an android block in the top-level build.gradle for the project, only in the module's build.gradle file.
This happened to me when AndroidStudio tried to import and existing, buildable Eclipse/ADT project–I had to cut and paste the android block from one gradle file to the other. I don't know if this has been fixed in more recent versions of AndroidStudio.
When downloading an open source project from GitHub, when importing into Android Studio , prompt
Gradle DSL method not found: 'android ()'

Most of the online search solutions are to delete the code in build.gradle similar to the following:
android {
compileSdkVersion 'Google Inc.:Google APIs: 23'
buildToolsVersion '23 .0.3 '
}
After deleting it, I found that it really works, no longer report an error.
I ’m not sure whether it will affect the normal execution of the project. After comparing the differences between the contents of this build.gradle before and after the project import, it is found that this configuration code is automatically added by the IDE after importing Android Studio . This section does not exist in the original project code.
You can refer to SO's detailed discussion: http://stackoverflow.com/questions/26759755/error1-0-gradle-dsl-method-not-found-android.

No comments:

Post a Comment