Android 实施项目';:app&x27;在';libModule';不起作用
我需要在Android Studio中创建模块,该模块将包含对主项目的依赖关系。我创建了新的项目和模块,将实现添加到库gradle中,如下所示:Android 实施项目';:app&x27;在';libModule';不起作用,android,gradle,android-library,android-module,Android,Gradle,Android Library,Android Module,我需要在Android Studio中创建模块,该模块将包含对主项目的依赖关系。我创建了新的项目和模块,将实现添加到库gradle中,如下所示: implementation project(':app') 但当我尝试同步gradle时,我遇到了下一个错误: Unable to resolve dependency for ':mylibrary@debug/compileClasspath': Could not resolve project :app. Unable to resolv
implementation project(':app')
但当我尝试同步gradle时,我遇到了下一个错误:
Unable to resolve dependency for ':mylibrary@debug/compileClasspath': Could not resolve project :app.
Unable to resolve dependency for ':mylibrary@debugAndroidTest/compileClasspath': Could not resolve project :app.
Unable to resolve dependency for ':mylibrary@debugUnitTest/compileClasspath': Could not resolve project :app.
Unable to resolve dependency for ':mylibrary@release/compileClasspath': Could not resolve project :app.
Unable to resolve dependency for ':mylibrary@releaseUnitTest/compileClasspath': Could not resolve project :app.
你知道它为什么会发生以及如何修复吗
更新
这是应用程序gradle(相当空)
这是格雷德尔图书馆:
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':app')
}
你想在第二个项目中添加库吗?我需要库,它将了解主项目编码。你可以发布你的
build.gradle
文件吗?@p.alexey,请看一看。我用gradle文件更新了我的问题,我遇到了同样的问题。目前有两种解决方法。1.您可以将内置模块从“android.application”更改为“android.library 2”。您将依赖项作为imtplementation项目(路径:':app',配置:'default')包括在内,我不知道为什么这不起作用。
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':app')
}