android - 在 app 模块中使用 buildSrc 模块版本

标签 android gradle android-module

我关注 this tutorial关于如何在我的 Android 应用程序中使用 Kotlin 管理 Gradle 依赖项,现在我想在我的应用程序模块中使用我的 Versions 对象中定义的版本(场景是我有一个开源屏幕,我想显示库版本) .我怎样才能做到这一点?

我尝试将 buildSrc 目录添加到 settings.gradle:

include ':app', ':buildSrc' 

然后在我的 build.gradle 文件中,将其添加到依赖项 block 中:
dependencies {
    implementation project(':buildSrc')
}

但是,当我尝试编译和运行时,会抛出以下错误:
Don't know how to compute maven coordinate for artifact 'Gradle API' with component identifier of type 'class org.gradle.internal.component.local.model.OpaqueComponentIdentifier'.

并且网络上没有太多关于此错误的信息。

最佳答案

尝试从您的设置和 build.gradle 中删除 buildSrc 模块。它自动构建并可供该项目中的所有其他模块访问。

关于android - 在 app 模块中使用 buildSrc 模块版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58902504/

相关文章:

java - Android中SdCard路径的正确路径?

android - 收缩资源不适用于库模块

java - 在本地 Maven 存储库中发布存档

JavaFX 到 Android

android 动态 Assets 交付

Android Studio - 如何在 Java/Kotlin 模块中指定 "-jvm-target"选项?

android - 在 Iphone 和 Android 上完成 AES 加密

java - 在android工作室:how I can create two tables with references?

java - 图像未从 Firebase 存储加载

android - 使用Robolectric运行JUnit测试时出现Gradle和Android Studio问题