2016-06-29 4 views
0

Я получил эту ошибку и попытался очистить проект и перестроить его. Но это не работает.
А также я пытался удалить некоторые коды из градиента, но все еще не работал.gradle dsl method not found 'android()' error (19 0)

Просьба сообщить.
Спасибо.

Ошибка:

Это build.gradle

// 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:2.1.2' 
//  classpath 'com.google.gms:google-services:1.3.0-beta1' 
     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 
allprojects { 
    repositories { 
     jcenter() 
    } 
} 

android { 
    compileSdkVersion 21 
    buildToolsVersion '20.0.0' 
} 
dependencies { 
} 

Это из приложения \ build.gradle

apply plugin: 'com.android.application' 
//apply plugin: 'com.google.gms.google-services' 

android { 
    compileSdkVersion 21 
    buildToolsVersion "20.0.0" 

    defaultConfig { 
     applicationId "me.kevingleason.pubnubchat" 
     minSdkVersion 15 
     targetSdkVersion 21 
     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.pubnub:pubnub-android:3.7.4' 
    compile 'com.google.android.gms:play-services:7.5.0' 
} 

ответ

0

Попробуйте следующее, и посмотреть, если оно работает. Кроме того, предоставьте мне версию андроид-студии, которую вы используете и создаете версию инструментов.

build.gradle

// 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:2.1.2' 

    // 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 
} 

приложение/build.gradle

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 21 
buildToolsVersion '24.0.0' //replace with your buildtoolsversion here 

defaultConfig { 
    applicationId "me.kevingleason.pubnubchat" 
    minSdkVersion 15 
    targetSdkVersion 21 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    provided 'com.android.support:support-annotations:23.3.0' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
    compile 'com.google.android.gms:play-services:9.0.2' 
    compile 'com.android.support:support-v4:23.4.0' 
    compile 'com.pubnub:pubnub-android:3.7.4' //erase if error is given and recompile 
} 
0

Вы проблема, во-первых, в вашем внешнем buil.gradle второй dependencies. На самом деле это точно 19-я строка из сообщения об ошибке. Удалите его (в конце первого):

dependencies { 
} 

Тогда есть NOTE комментарий несколько строк выше с указанием:

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

Так, как правило, не забудьте всегда ставить свою зависимость в app-module build.gradle, а не один из них.

Упование вы считаете это полезным.

Смежные вопросы