找不到参数的方法compile()[com.android.support:cardview-v7:27.0.2]

时间:2018-01-16 18:33:02

标签: java android maven

我试图合并两个项目。我的SDK已更新,但每次运行代码时都会收到此错误。

Error:(19, 0) Could not find method compile() for arguments 
[com.android.support:cardview-v7:27.0.2] on object of type 
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.

我的所有支持存储库都已下载。一直在寻找这个解决方案太久,但失败了。 这是我的 android / app / build.gradle 文件的代码。

apply plugin: 'com.android.application'

android {
     compileSdkVersion 27
defaultConfig {
    applicationId "pingo.betnek.hospiva"
    minSdkVersion 17
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
}
}

repositories {

    mavenCentral()
 }

allprojects {
repositories {
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:27.0.2'
//    compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.github.f0ris.sweetalert:library:1.5.1'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-storage:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.android.support:recyclerview-v7:27.0.2'
testCompile 'junit:junit:4.12'

// For Alert Notifications from top
compile 'com.tapadoo.android:alerter:2.0.1'
 }



apply plugin: 'com.google.gms.google-services'

请帮我解决这个问题。

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,只是将其改为

compile "com.android.support:appcompat-v7:27.0.0"