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

标签 android android-gradle-plugin 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'
}

最佳答案

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

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

同时检查 gradle used 的版本在 gradle/wrapper/gradle-wrapper.properties 文件中:

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

关于android - Gradle 同步失败找不到方法实现(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54996664/

相关文章:

android - 毕加索和httpClient无法解析

android - 错误 : unknown tag <:string> in my app

android - 当屏幕关闭时,AsyncTask 中的代码无法顺利运行

android - 定位纸屑

java - .class 到 .dex 的转换

当项目位于 Github 的子文件夹中时,Android Studio 构建错误

Liferay - 使用第三方库不起作用

java - 在gradle中调用自定义任务

java - Firebase Firestore 在运行时错误时崩溃

java - 使用 JNI 从 Android 调用预构建的 C++ 共享库