错误:当我用gradle(dependency)中的实现替换compile时 [英] Error: when I replace compile with implementation in gradle(dependency)
问题描述
我将Android Studio从3.0.1更新为3.1.0
I update my Android Studio from 3.0.1 to 3.1.0
但是在更新后,当我构建项目时,它会显示 2警告:
But after the update when I build my project it shows 2 warning:
1.将编译替换为实现(编译支持将于2018年底终止)
1. Replace compile with implementation (and compile support will be ended at end of 2018)
2.将testCompile替换为testImplementaion (并将在2018年底终止对testCompile的支持)
2. Replace testCompile with testImplementaion (and testCompile support will be ended at end of 2018)
因此,最后进行这些更改,但之后,它会显示一些错误:
So, finally do these changes but after that, it shows some error:
build.gradle(Module:app)
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)
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
}
推荐答案
尝试在库的gradle中使用api
而不是implementation
.如果您有子模块并希望以传递方式公开库,则应使用api
. implementation
将导入特定项目的库.另外,您可能需要添加
Try using api
instead of implementation
inside your library's gradle. If you have submodules and want to expose the libraries in a transitive manner api
should be used. implementation
would import the library for the specific project. Also you might have to add
implementation (project(":library")) {
transitive = true
}
例如在库模块的build.gradle
文件中使用:
For example in your build.gradle
file of your library module use:
api 'com.android.support:appcompat-v7:27.1.0'
代替
implementation 'com.android.support:appcompat-v7:27.1.0'
如果没有任何效果,您可以尝试使缓存无效并重新启动
If nothing works you can try to invalidate cache and restart
这篇关于错误:当我用gradle(dependency)中的实现替换compile时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!