关于android:使用jitpack构建的库中的错误:无法解析’:app @ debug / compileClasspath’的依赖关系

Error in library built with jitpack: Unable to resolve dependency for ':app@debug/compileClasspath'

我试图在jitpack.io上发布我的android库,但是当我尝试添加依赖项来测试我的工件时,却出现此错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details


Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.github.pashaoleynik97:GSBarcodeScannerHelper:0.1.1-alpha.
Open File
Show Details

下面列出了我在图书馆项目中的gradle文件。

我的build.gradle(应用程序):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId"com.github.pashaoleynik97.gsbarcodescannerhelperdemo"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 2
        versionName"1.1"
        testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation project(':gsbarcodescannerhelper')
}

我的build.gradle(gsbarcodescannerhelper):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
apply plugin: 'com.android.library'
group='com.github.pashaoleynik97;'

android {
    compileSdkVersion 28



    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 2
        versionName"0.1.1"

        testInstrumentationRunner"android.support.test.runner.AndroidJUnitRunner"

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.10'
    implementation(name: 'generalscan-sdk-1.0.6', ext:'aar')
}

最后,我的build.gradle(项目):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs project(':gsbarcodescannerhelper').file('libs')
        }
        maven { url 'https://jitpack.io' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我将项目推送到github,创建发布(通过github Web界面),然后转到jitpack.io并发布了我的库。 但是,当我尝试将此库添加到我的新测试项目中时,出现了错误(列在本文的顶部)。 我做错了什么?

UPD

我还尝试在此文档中添加classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1':https://jitpack.io/docs/ANDROID/
但是结果保持不变。

UPD 2

创建的问题:https://github.com/jitpack/jitpack.io/issues/3758


这似乎是一个持续存在的问题,可以在这里找到,该链接在此处提到了一种解决方法。解决方法是在jitpack.io中添加www。因此,将其更新为以下内容:

1
maven { url 'https://www.jitpack.io' }

Jitpack是非常敏感的工具。出现此问题的原因有多种。我将尝试逐项列出。

1)单元测试失败;如果单元测试失败,则可以在jitpack上创建工件(没有报告的问题),但是将无法引用该工件。确保所有单元测试均正常运行。

2)建议您在要用作项目的项目的项目级别gradle中包括以下内容:

项目级别摇篮的顶部

1
2
apply plugin: 'maven-publish'
group = ''

在项目级别的最底部,gradle包括

1
apply from: 'https://raw.githubusercontent.com/sky-uk/gradle-maven-plugin/master/gradle-mavenizer.gradle'

现在生成一个工件,看看引用是否有效

3)私人神器?也许您没有正确引用工件。如果您的回购是私人的,请确保在gradle.properties中添加auth令牌,然后像这样在项目级gradle上对其进行引用,

gradle.properties

1
authToken=jp_myfake_token

项目级别爬虫:

1
2
3
4
maven {
            url"https://jitpack.io"
            credentials{ username authToken }
        }

4)等待一个小时。无论出于何种原因,Jitpack都存在同步和缓存问题。有时您所要做的就是等待一个小时(或两个小时),然后一切开始工作。

希望其中之一可以帮助您解决问题。 Jitpack设置简单,但是有很多问题。


现在,它仅对公共存储库免费。
如果将存储库URL放在https://jitpack.io中并进行查找,您将看到以下消息作为日志:

Subscription not active


确保您添加maven { url"https://jitpack.io" }

build.gradle(项目级别)中,如下所示:

1
2
3
4
5
6
7
allprojects {
    repositories {
        google()
        jcenter()
        maven { url"https://jitpack.io" }
    }
}

此外,请确保已禁用您的Gradle离线模式