我想将一个 android studio 项目导入另一个 android studio 项目。所以我已将它作为模块导入到 android studio 项目中。此消息项目已经有在项目中使用的模块。我已成功在 android studio 中导入消息项目。但是当我添加一个依赖时它没有显示这个模块,所以请检查我已经导入的图像以及如何添加消息模块的依赖。
我努力了
implementation project(':message')
但是出现错误
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve project :message. Show Details Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve project :message.
Show Details Affected Modules: app
ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve project :message. Show Details Affected Modules: app
最佳答案
你应该有这样的结构:
-rootApp
|--build.gradle
|--settings.gradle
|--app
|----build.gradle
-rootMessage
|--build.gradle
|--settings.gradle
|--vcard
|----build.gradle
在项目中,您可以引用外部模块。
只需使用:
在
rootApp/settings.gradle
:include ':app'
include ':myExternalLib'
project(':myExternalLib').projectDir=new File('/path-to-project/rootMessage/vcard')
在
app/build.gradle
:dependencies {
implementation project(':myExternalLib')
}
注意 myExternalLib。
您必须在另一个项目中使用库的路径,而不是项目的根目录。
在您的情况下,路径是
rootMessage/vcard
.此外,
rootMessage/settings.gradle
不会被读取,因为您正在使用 rootApp 项目。
关于android - 将 Android Studio 项目导入为模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56642248/