Gradle同步失败找不到方法实现()

时间:2019-03-05 06:28:44

标签: android android-gradle build.gradle gradle-plugin

11:14 AM    Gradle sync failed: Could not find method implementation() for arguments [directory 'libs'] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. (1 s 851 ms)

我打开了一个项目,然后遇到了问题。有没有人帮我解决这个问题?

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.app.androidlivetv"
        manifestPlaceholders = [manifestApplicationId: "${applicationId}",
                                onesignal_app_id: "0e611d58-a9f2-4665-80c0-3334f0756f82",
                                onesignal_google_project_number: "REMOTE"]
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes.each{
        it.buildConfigField 'String', 'SERVER_URL', serverUrl
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:exifinterface:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'me.relex:circleindicator:1.2.2@aar'
    implementation 'com.github.ornolfr:rating-view:0.1.2@aar'
    implementation 'cn.gavinliu.android.lib:ShapedImageView:0.8.4'
    implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.onesignal:OneSignal:3.9.1@aar'
    implementation 'com.google.android.gms:play-services-cast-framework:15.0.1'
    implementation 'com.android.support:mediarouter-v7:27.1.1'
    implementation 'com.mobsandgeeks:android-saripaar:2.0.2'
    implementation 'com.github.ixiDev:GDPRChecker:v0.2'
    implementation 'com.google.android.ads.consent:consent-library:1.0.6'
    implementation 'com.github.halilozercan:BetterVideoPlayer:1.1.0'
    implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
    implementation project(':vitamio')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

1 个答案:

答案 0 :(得分:0)

在顶级build.gradle中更新android gradle plugin的版本。

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

还要检查gradle/wrapper/gradle-wrapper.properties文件中gradle used的版本:

distributionUrl = https\://services.gradle.org/distributions/gradle-4.10.1-all.zip