我正在尝试在 Android Studio (3.1) 中创建一个包含 Android 库和 Java 库的项目。 Java 库依赖于 Android 库。两者都是我项目中的模块,如下所示:
MyProject
|-android
|-java
include ':android', ':java'
build.gradle
):apply plugin: 'java-library'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':android')
}
...
build.gradle
):apply plugin: 'com.android.library'
...
Failed to resolve: project::android
首先让我们尝试修复构建错误。让我们运行 ./gradlew build --stacktrace
来查看更详细的输出:
Caused by: org.gradle.internal.component.AmbiguousConfigurationSelectionException:
Cannot choose between the following configurations of project :androidLibrary:
- debugApiElements
- releaseApiElements
implementation project(path: ':androidLibrary', configuration: 'default')
尝试将项目与该设置同步后,您将在控制台中看到以下输出:Ignoring dependency of module 'androidLibrary' on module 'javaLibrary'. Java modules cannot depend on Android modules
关于java - 无法解析项目 : Android library and Java library module dependency,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49714744/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |