[英]Add (external) local library project as dependency in Android Studio
I am trying to add a local library project that I cloned (and modified a bit) from Github ( Android-ReactiveLocation ) as a dependency to my application.我正在尝试添加一个我从 Github ( Android-ReactiveLocation )克隆(并稍作修改)的本地库项目作为我的应用程序的依赖项。
According to this answer it should be as easy as:根据这个答案,它应该很简单:
settings.gradle
include(':reactivelocation')
project(':reactivelocation').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation')
build.gradle
in my app directory我的应用程序目录中的
build.gradle
dependencies {
...
compile project(':reactivelocation')
}
Unfortunately I get the error不幸的是我得到了错误
Error:Configuration with name 'default' not found.
错误:未找到名称为“默认”的配置。
As soon as I add the compile
statement.只要我添加
compile
语句。 What am I doing wrong?我究竟做错了什么?
I also tried to use compile project(':reactivelocation:android-reactive-location')
as I am only interested in this module library inside Android-ReactiveLocation
, but this also fails我也尝试使用
compile project(':reactivelocation:android-reactive-location')
因为我只对Android-ReactiveLocation
中的这个模块库感兴趣,但这也失败了
Project with path ':reactivelocation:android-reactive-location' could not be found in project.
在项目中找不到路径为 ':reactivelocation:android-reactive-location' 的项目。
Update.更新。 Some other things I tried without success (same error):
我尝试过的其他一些事情没有成功(同样的错误):
settings.gradle
include(':android-reactive-location') project(':android-reactive-location').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation/android-reactive-location')
build.gradle
in my app diretory build.gradle
在我的应用程序目录中
dependencies { ... compile project(':android-reactive-location') }
settings.gradle
include(':Android-ReactiveLocation') project(':Android-ReactiveLocation').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation')
build.gradle
in my app diretory build.gradle
在我的应用程序目录中
dependencies { ... compile project(':Android-ReactiveLocation') }
settings.gradle
include(':Android-ReactiveLocation:android-reactive-location') project(':Android-ReactiveLocation:android-reactive-location').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation/') // also with '../Andrdoid-ReactiveLocation/android-reactive-location'
build.gradle
in my app diretory build.gradle
在我的应用程序目录中
dependencies { ... compile project(':Android-ReactiveLocation:android-reactive-location') }
I have a similar scenario in my project. 我的项目中也有类似的情况。 In
build.gradle
in app
directory you should add path
before the library name: 在
app
目录的build.gradle
中,您应该在库名称之前添加path
:
compile project(path: ':reactivelocation')
In my project every things work whit above line. 在我的项目中,一切都超出了预期。 My
settings.gradle
is exactly like yours. 我的
settings.gradle
与您完全一样。
A bit late to the party here.在这里聚会有点晚了。 But, are you aware that the directory you listed in the settings, might have a typo?
但是,您是否知道您在设置中列出的目录可能有错字?
include(':reactivelocation')
project(':reactivelocation').projectDir = new File(settingsDir, '../Andrdoid-ReactiveLocation')
^^^^^^^^
Perhaps this should be, as the project you have cloned named, Android-ReactiveLocation
也许这应该是,作为您克隆的项目,
Android-ReactiveLocation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.