我想添加jitpack。IO作为一个存储库在我的gradle文件。
这是我的gradle根文件:
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
因为我没有一个“allrepositories”来把我的依赖放在那里(只在那里工作),我已经创建并在buildscript代码后添加了这段代码:
allprojects {
repositories {
maven {url 'https://www.jitpack.io'}
}
}
但这是我得到的错误
Caused by: org.gradle.api.InvalidUserCodeException: Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'
您需要在“设置”中更新设置。gradle和更改repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)为repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
最后,添加maven {url 'https://jitpack。Io '}到存储库块。
完整的设置。Gradle文件看起来是这样的:
import org.gradle.api.initialization.resolve.RepositoriesMode
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "appname"
include ':app'
随着Android工作室的更新,你必须控制你的依赖设置。app
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url 'https://jitpack.io' }
}
} rootProject.name = "EmfDetector"
包括:应用程序的
请把这条线放在呼吸器上
maven { url 'https://jitpack.io' } //as i have done above
`
您需要在“设置”中更新设置。gradle和更改repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)为repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
最后,添加maven {url 'https://jitpack。Io '}到存储库块。
完整的设置。Gradle文件看起来是这样的:
import org.gradle.api.initialization.resolve.RepositoriesMode
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "appname"
include ':app'