在 Android Studio 项目中添加外部项目作为依赖导致错误找不到文件
Add external project in Android Studio project as dependency results in error not finding a file
我目前正在尝试添加 https://github.com/firebase/FirebaseUI-Android 的本地克隆作为我项目中的依赖项。我不想通过标准方式导入它,因为我想对 FirebaseUI 进行修改。目前我正在尝试这个:
settings.gradle:
include ':firebaseui'
project(':firebaseui').projectDir = new File(settingsDir, '../FirebaseUI')
我的模块的build.gradle:
dependencies {
compile project(":firebaseui")
}
但我得到:
Error:(42, 0) Could not read script 'C:\Users\Gonzalo\AndroidStudioProjects\MyProject\common\constants.gradle' as it does not exist.
导入到FirebaseUI\build.gradle:
allprojects { project ->
// Get constants, this is where we store things
// like the list of submodules or the version
project.apply from: "$rootDir/common/constants.gradle"
...
是 FirebaseUI 的 build.gradle 还是我的问题?
通过 mavenLocal()
存储库使用二进制依赖:
git clone https://github.com/firebase/FirebaseUI-Android
cd FirebaseUI-Android
gradlew tasks
// 你会看到 publishToMavenLocal
- 打开
FirebaseUI-Android
进入一个单独的 Intellij 实例
- 进行更改
- 运行
gradlew publishToMavenLocal
- 在您自己的项目中,将
mavenLocal()
添加到您的 repositories
- 然后添加
compile 'com.firebaseui:firebase-ui:0.4.1'
做你的 dependencies
完成所有这些后,您就可以开始了。
- 对库进行更改
- 通过
gradlew publishToMavenLocal
再次发布
- 重新编译您的应用程序
问题在于 $rootDir
的含义。如果您尝试仅构建 firebase 代码,则其父 $rootDir returns 是其父文件夹。 constants.gradle 的相对位置是有效的。
现在,当您将 firebase 添加为项目的子项目时,$rootDir 现在是您的根目录,$rootDir/common/constants.gradle
不再是有效路径。您可以将路径替换为:
$rootDir../FirebaseUI/common/constants.gradle
但是,除非您对 firebase 代码进行本地更改,否则我会赞同 Jared 的建议,使用来自 maven 存储库的二进制依赖项。
我目前正在尝试添加 https://github.com/firebase/FirebaseUI-Android 的本地克隆作为我项目中的依赖项。我不想通过标准方式导入它,因为我想对 FirebaseUI 进行修改。目前我正在尝试这个:
settings.gradle:
include ':firebaseui'
project(':firebaseui').projectDir = new File(settingsDir, '../FirebaseUI')
我的模块的build.gradle:
dependencies {
compile project(":firebaseui")
}
但我得到:
Error:(42, 0) Could not read script 'C:\Users\Gonzalo\AndroidStudioProjects\MyProject\common\constants.gradle' as it does not exist.
导入到FirebaseUI\build.gradle:
allprojects { project ->
// Get constants, this is where we store things
// like the list of submodules or the version
project.apply from: "$rootDir/common/constants.gradle"
...
是 FirebaseUI 的 build.gradle 还是我的问题?
通过 mavenLocal()
存储库使用二进制依赖:
git clone https://github.com/firebase/FirebaseUI-Android
cd FirebaseUI-Android
gradlew tasks
// 你会看到publishToMavenLocal
- 打开
FirebaseUI-Android
进入一个单独的 Intellij 实例 - 进行更改
- 运行
gradlew publishToMavenLocal
- 在您自己的项目中,将
mavenLocal()
添加到您的repositories
- 然后添加
compile 'com.firebaseui:firebase-ui:0.4.1'
做你的dependencies
完成所有这些后,您就可以开始了。
- 对库进行更改
- 通过
gradlew publishToMavenLocal
再次发布
- 重新编译您的应用程序
问题在于 $rootDir
的含义。如果您尝试仅构建 firebase 代码,则其父 $rootDir returns 是其父文件夹。 constants.gradle 的相对位置是有效的。
现在,当您将 firebase 添加为项目的子项目时,$rootDir 现在是您的根目录,$rootDir/common/constants.gradle
不再是有效路径。您可以将路径替换为:
$rootDir../FirebaseUI/common/constants.gradle
但是,除非您对 firebase 代码进行本地更改,否则我会赞同 Jared 的建议,使用来自 maven 存储库的二进制依赖项。