Android Gradle-实现,releaseImplementation和debugImplementation之间的区别

nut*_*les 5 android android-gradle-plugin

我在Android Studio中有一个Android应用程序。我正在使用Gradle Version = 4.6, Android Plugin Version=3.2.1.。它具有一个应用程序模块(主)和一个库模块。

我重命名了library模块中的类函数之一。清洁并构建library模块,然后构建模块之后app,我在app模块中收到此错误:error: cannot find symbol to the renamed class function

以下是我的build.gradle(app):

android {
...
}
dependencies {
...
  releaseImplementation 'com.example.library:1.0.0'
  debugImplementation project(':library')
}
Run Code Online (Sandbox Code Playgroud)

如果我将build.gradle更改为以下内容,则一切正常。

android {
}
dependencies {
...
  implementation project(':library')
}
Run Code Online (Sandbox Code Playgroud)

我想知道之间的差异implementationreleaseImplementation以及debugImplementation,我怎么可以用它在我的处境。

Vin*_*tti 6

implementation将依赖项应用于所有构建变体。相反,如果您只想声明特定构建变体源集或测试源集的依赖关系,则必须大写配置名称,并在其前面加上构建变体或测试源集的名称。

例如:如果你要消耗的调试,释放和自由生成单独的依赖变体(my-library-debugmy-librarymy-library-free分别),那么你必须使用debugImplementationreleaseImplementationfreeImplementation如下

debugImplementation 'com.test.package:my-library-debug:1.0' 

releaseImplementation 'com.test.package:my-library:1.0' 

freeImplementation 'com.test.package:my-library-free:1.0' 
Run Code Online (Sandbox Code Playgroud)

在这里阅读更多(您也可以将产品风格和构建类型结合起来,以针对更具体的构建变体):https : //developer.android.com/studio/build/dependencies#dependency_configurations


归档时间:

查看次数:

1444 次

最近记录:

6 年,2 月 前