android - 无法将 git 存储库解析为 android gradle 中的依赖项
问题描述
我正在尝试使用 Gradle 将 git 存储库(https://github.com/FHNW-IP5-IP6/ComposeForms)作为依赖项添加到我的项目中,并尝试了以下列出的变体(1.-3)。可以在 android gradle 中将 git 存储库声明为依赖项吗?但每次同步项目时,我都会收到一条错误消息:“Could not resolve com.github.FHNW-IP5-IP6:ComposeForms:master-SNAPSHOT”。
我尝试了以下方法:
Jitpack ( https://jitpack.io/#FHNW-IP5-IP6/ComposeForms/master-SNAPSHOT )
allprojects { repositories { ... maven("https://jitpack.io") // also tried uri https://www.jitpack.io } }
并在应用程序 build.gradle
kotlin { sourceSets { named("main") { dependencies { ... implementation("com.github.FHNW-IP5-IP6:ComposeForms:master-SNAPSHOT") } } } }
Git 子模块(命名为 compose-forms)
include(":compose-forms")
在 settings.gradle 里面kotlin { sourceSets { named("main") { dependencies { ... implementation(project(":compose-forms")) } } } }
gradle 中的新功能
里面 settings.gradle
sourceControl { gitRepository(uri("https://github.com/FHNW-IP5-IP6/ComposeForms.git")) { producesModule("compose-forms") } }
并在应用程序 build.gradle
kotlin { sourceSets { named("main") { dependencies { ... implementation("compose-forms") { version { branch = "master" } } } } } }
我用完了选项,真的需要 git 存储库作为依赖项。我不希望我的项目中有任何 git 子模块,所以我更喜欢数字 1 和 3 工作。提前感谢您的任何提示:)
解决方案
以管理员身份打开 Android Studio,然后将maven { url 'https://jitpack.io' }添加到build.gradle(project)和settings.gradle(project)以及各自的实现 [...]到build.gradle( :应用程序)。这对我有用,因为提出的所有其他解决方案都失败了。
推荐阅读
- c# - Xamarin.Forms 使用 API
- c++ - 当 LIBS += -L"..." 似乎不起作用时,如何在 Qt Creator 中链接外部库?
- c# - 即使在数据集和 SQL Server Management Studio 中更改数据类型后也会出错
- laravel - 如何更改 twilio verify 发送的 OTP 消息的默认消息文本
- xml - 如何使用 Xquery 按顺序获取节点的相同属性值?
- javascript - 关于与异步函数相关的 React 组件运行顺序的问题
- javascript - 如何在react-hook-form中的react-select中使用useEffect中的条件defaultValues?
- javascript - 内部/模块/cjs/loader.js:883 抛出错误;
- java - 检查拆分字符串的值是否在下面的字符串中
- jsf-2.2 - 如何确定 h:graphicImage 中不同区域的坐标