简体   繁体   English

错误:当我用 gradle 中的实现替换编译时(依赖)

[英]Error: when I replace compile with implementation in gradle(dependency)

I update my Android Studio from 3.0.1 to 3.1.0我将我的 Android Studio 从 3.0.1 更新到 3.1.0

But after the update when I build my project it shows 2 warning :但是在我构建项目的更新之后,它显示了2 个警告

1. Replace compile with implementation (and compile support will be ended at end of 2018) 1. 用实现替换编译(编译支持将在2018年底结束)

2. Replace testCompile with testImplementaion (and testCompile support will be ended at end of 2018) 2. 将 testCompile 替换为 testImplementaion (并且 testCompile 支持将在 2018 年底结束)

So, finally do these changes but after that, it shows some error :所以,最后做这些改变,但在那之后,它显示了一些错误

错误

build.gradle(Module:app) build.gradle(模块:应用程序)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "biz.coolpage.aashish.app"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 4
        versionName "1.2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:27.1.0'
    implementation project(':library')
}

build.gradle(Project:Abc) build.gradle(项目:ABC)

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

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

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

Try using api instead of implementation inside your library's gradle.尝试使用api ,而不是implementation图书馆的内部的gradle。 If you have submodules and want to expose the libraries in a transitive manner api should be used.如果您有子模块并希望以可传递的方式公开库,则应使用api implementation would import the library for the specific project. implementation将导入特定项目的库。 Also you might have to add你也可能需要添加

implementation (project(":library")) {
    transitive = true
}

For example in your build.gradle file of your library module use:例如在你的库模块的build.gradle文件中使用:

api 'com.android.support:appcompat-v7:27.1.0' 

instead of而不是

implementation 'com.android.support:appcompat-v7:27.1.0'

If nothing works you can try to invalidate cache and restart如果没有任何效果,您可以尝试使缓存无效并重新启动

Been there;去过那里; just make sure your gradle plugin is up to date and you didn't add or remove anything to the plugins source code and you're good to go只需确保您的 gradle 插件是最新的,并且您没有在插件源代码中添加或删除任何内容,您就可以开始了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM