错误:当我用 gradle 中的实现替换编译时(依赖) [英] 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(并且 testCompile 支持将于 2018 年底结束)
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 中的实现替换编译时(依赖)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!