首页 > 解决方案 > 无法解析配置“: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
}

标签: androidgradleeasyimage

解决方案


要解决这个问题,只需添加jitpackgradle 项目文件,

allprojects {
    repositories {
        google()
        jcenter()
        maven { url 'https://jitpack.io' }
    }
}

推荐阅读