找不到参数[com.android.support:appcompat-v7:28.0.0]的方法Implementation()

时间:2018-12-08 03:08:30

标签: java android android-studio

Build.gradle(项目):

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

        implementation 'com.android.support:appcompat-v7:28.0.0'
        implementation 'com.android.support:customtabs:28.0.0'
        implementation 'com.android.support:support-vector-drawable:28.0.0'
        implementation 'com.android.support:support-media-compat:28.0.0'
        implementation 'com.android.support:support-v4:28.0.0'

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

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url "https://maven.google.com"
            name 'Google'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Build.gradle(模块):

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion 28.0
    defaultConfig {
        applicationId 'com.shiba.honey'
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
        ignoreWarnings true //false
    }
    buildToolsVersion '28.0.3'
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-ads:17.1.2'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'

}

当我同步时出现此错误:

  

找不到参数的方法Implementation()   [com.android.support:appcompat-v7:28.0.0]类型的对象   org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。

     

请从Android SDK安装Android支持存储库   经理。打开Android SDK Manager

我从Android SDK安装了所有支持存储库,但不知道该怎么办.....

1 个答案:

答案 0 :(得分:0)

尝试一下:

在build.gradle(Project)中:

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'

     // NOTE : REMOVE IMPLEMENTATION FILES FROM HERE AND USE THEM IN DEPENDENCIES IN BUILD.GRADLE(APP).
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "$rootDir/../node_modules/react-native/android"
        }
        maven {
            url "https://maven.google.com"
            name 'Google'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

在build.gradle(app)中执行此操作:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion 28.0
    defaultConfig {
        applicationId 'com.shiba.honey'
        minSdkVersion 14
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
        ignoreWarnings true //false
    }
    buildToolsVersion '28.0.3'
    productFlavors {
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.google.android.gms:play-services-ads:17.1.2'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    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'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:customtabs:28.0.0'
    implementation 'com.android.support:support-vector-drawable:28.0.0'
    implementation 'com.android.support:support-media-compat:28.0.0'
    implementation 'com.android.support:support-v4:28.0.0'

}