2017-10-14 63 views
0

我不斷收到這個錯誤,當我嘗試在Android Studio中運行我的應用程序搖籃同步錯誤的根項目給錯誤

Error:(20, 0) Could not find method android() for arguments [[email protected]] on root project 'pomppyapp' of type org.gradle.api.Project. Open File

這是我的build.gradle(項目:pomppyapp)

// 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.3.3' 
    classpath 'com.google.gms:google-services:3.0.0' 

    // NOTE: Do not place your application dependencies here; they belong 
    // in the individual module build.gradle files 2.3.3 
} 
} 
allprojects { 
repositories { 
    jcenter() 
} 
} 

android { 
compileSdkVersion 26 
buildToolsVersion '26.0.2' 
} 
dependencies { 
} 

也是另一個文件中有所謂的build.gradle(模塊:APP)與下列:

apply plugin: 'com.android.application' 
android { 
compileSdkVersion 26 
buildToolsVersion '26.0.2' 

defaultConfig { 
    applicationId "com.pomppyapp.com" 
    minSdkVersion 15 
    targetSdkVersion 23 
    versionCode 12 
    versionName '1.6' 

} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     debuggable false 
     jniDebuggable false 
    } 
} 

lintOptions { 
    checkReleaseBuilds false 
    // Or, if you prefer, you can continue to check for errors in release builds, 
    // but continue the build even when errors are found: 
    abortOnError false 
} 

productFlavors { 
} 
} 
dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
compile 'com.mcxiaoke.volley:library:1.0.18' 
compile 'com.github.chrisbanes.photoview:library:1.2.3' 
compile 'com.facebook.android:facebook-android-sdk:4.0.1' 
compile 'com.google.android.gms:play-services-ads:11.0.4' 
compile 'com.pkmmte.view:circularimageview:1.1' 
compile 'com.melnykov:floatingactionbutton:1.3.0' 
compile 'com.github.bumptech.glide:glide:3.7.0' 
compile 'com.android.support:appcompat-v7:25.3.1' 
compile 'com.android.support:cardview-v7:25.3.1' 
compile 'com.android.support:recyclerview-v7:25.3.1' 
compile 'com.android.support:design:25.3.1' 
compile 'com.google.firebase:firebase-messaging:9.0.0' 
compile 'com.balysv:material-ripple:1.0.2' 
compile 'com.squareup.picasso:picasso:2.5.2' 
compile 'com.squareup.okhttp:okhttp:2.5.0' 
compile 'com.android.tools.build:gradle:2.3.0' 
} 
apply plugin: 'com.google.gms.google-services' 

任何幫助不勝感激,提前致謝。

回答

0

我想,在你的gradle頂級構建文件這一部分是錯誤的:

android { compileSdkVersion 26 buildToolsVersion '26.0.2' }

應該只停留在項目gradle.build文件(在這種情況下模塊:應用程序)

+0

這工作,謝謝 – Acidload

0

您應該從項目級別build.gradle中刪除這些行,因爲沒有應用Android Gradle插件。

android { 
    compileSdkVersion 26 
    buildToolsVersion '26.0.2' 
} 
dependencies { 
} 

它應該只在模塊級別的gradle文件中應用了android gradle插件。 :app在這種情況下,在其Android應用插件的gradle已經應用(apply plugin: 'com.android.application'

+0

這工作,謝謝 – Acidload

+0

不要忘記給予好評的答案,以便其他人也能發現它有用。 –

+0

我投了票,但它不會顯示,直到我做15。 – Acidload