android - 无法解析配置“:app:debugRuntimeClasspath gradle 子模块依赖项”的所有文件
问题描述
我有一个变成 Maven 存储库的子模块项目,我正在尝试使用implementation com.github.jkwiecien:EasyImage:3.0.3
其他类似Glide
作品的依赖项,但出现了这个问题:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.github.jkwiecien:EasyImage:3.0.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://jcenter.bintray.com/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://maven.google.com/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
- https://repo.maven.apache.org/maven2/com/github/jkwiecien/EasyImage/3.0.3/EasyImage-3.0.3.pom
Required by:
project :app > project : myapp
我尝试将 Maven 存储库作为:
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'
android {
compileSdkVersion 30
defaultConfig {
minSdkVersion 21
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
def githubProperties = new Properties()
githubProperties.load(
new FileInputStream(rootProject.file("github.properties"))
)
def getVersionName = { ->
return "1.0.9"
}
def getArtifactId = { ->
return "rewards"
}
publishing {
publications {
rewards(MavenPublication) {
groupId 'app.my.sdk'
artifactId getArtifactId()
version getVersionName()
artifact("$buildDir/outputs/aar/${getArtifactId()}-release.aar")
pom.withXml { // adding transitive dependencies...
final dependenciesNode = asNode().appendNode('dependencies')
ext.addDependency = { Dependency dep, String scope ->
if (dep.group == null || dep.version == null ||
dep.name == null || dep.name == "unspecified")
return
final dependencyNode = dependenciesNode
.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)
dependencyNode.appendNode('version', dep.version)
dependencyNode.appendNode('scope', scope)
if (!dep.transitive) {
final exclusionNode = dependencyNode
.appendNode('exclusions')
.appendNode('exclusion')
exclusionNode.appendNode('groupId', '*')
exclusionNode.appendNode('artifactId', '*')
} else if (!dep.properties.excludeRules.empty) {
final exclusionNode = dependencyNode
.appendNode('exclusions')
.appendNode('exclusion')
dep.properties.excludeRules.each { ExcludeRule rule ->
exclusionNode.appendNode(
'groupId', rule.group ?: '*')
exclusionNode.appendNode(
'artifactId', rule.module ?: '*')
}
}
} // end addDependency
configurations.compile.getDependencies().each { dep ->
addDependency(dep, "compile")
}
configurations.api.getDependencies().each { dep ->
addDependency(dep, "compile")
}
configurations.implementation.getDependencies().each { dep ->
addDependency(dep, "runtime")
}
} // end pomWithXml
}
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/my-project/my-lib")
credentials {
username = githubProperties['gpr.usr'] ?: System.getenv("GPR_USER")
password = githubProperties['gpr.key'] ?: System.getenv("GPR_API_KEY")
}
}
}
}
repositories {
maven {
URL "https://mvnrepository.com/artifact/com.github.jkwiecien/EasyImage"
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'jp.wasabeef:blurry:4.0.0'
implementation 'io.socket:socket.io-client:1.0.0'
implementation 'com.github.jkwiecien:EasyImage:3.0.3'
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
}
这是我的完整 gradle 文件。我只使用这个模块,它应该是另一个里面的一个应用程序。我正在使用 maven 在 github 包中上传。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
解决方案
要解决这个问题,只需添加jitpack
gradle 项目文件,
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
推荐阅读
- core-data - 带有 Core Data 的 SwiftUI:获取带有谓词崩溃的请求
- angular - 监听 RadListView 的滚动事件
- solr - Solr Repeaters/Slaves 复制是 Master 上的每次提交,而不是 Optimize
- c++ - 有偏随机数生成
- php - CSS 不会链接到我在 Wordpress 中的 page.php 模板,其他一切正常
- html - 如何仅使用 html 和 scss 在元素之前和之后分配不同的背景颜色?
- plot - 几个问题: 1. 打开或关闭枢轴高低功能。2.改变标签偏移距离
- python - 每次迭代后清空列表
- c# - C# Xamarin 在 TabbedPage 中使用 ObservableCollection 形成嵌套列表
- python-3.x - 如何使用 matplotlib 调整大小并显示带有补丁的裁剪图像?