【问题标题】:Android 3.0.1 does not resolve dependencyAndroid 3.0.1 不解决依赖
【发布时间】:2018-03-15 13:38:28
【问题描述】:

我想添加这些依赖项:

implementation 'com.andrognito.pinlockview:pinlockview:2.1.0'
implementation 'com.multidots:fingerprint-auth:1.0.1'

在带有 gradle 3.0.1 的 android studio 3.0.1 中,但出现以下错误:

无法解析 ':app@debug/compileClasspath' 的依赖关系:无法解析 com.multidots:fingerprint-auth:1.0.1。 无法解析 ':app@debugAndroidTest/compileClasspath' 的依赖关系:无法解析 com.andrognito.pinlockview:pinlockview:2.1.0。

我的build.gradle 文件是:

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

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

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        google()

    }
}

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

还有一个:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion '26.0.2'
    defaultConfig {
        applicationId "com.b.jacob.gallery"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:24.2.1'
    implementation 'com.android.support:design:24.2.1'
    implementation 'com.andrognito.pinlockview:pinlockview:2.1.0'
    implementation 'com.multidots:fingerprint-auth:1.0.1'
    testImplementation 'junit:junit:4.12'
}

重要的是说这些依赖关系在旧版本的 android studio 中解决没有任何问题。

【问题讨论】:

  • 你能不能先用谷歌改变 jcenter(),mavenCentral(),google() 存储库的顺序

标签: android android-gradle-plugin


【解决方案1】:
implementation 'com.android.support:appcompat-v7:24.2.1'
implementation 'com.android.support:design:24.2.1'

 buildToolsVersion '26.0.2'

不能一起去会有冲突

您的更改应该是:-

implementation 'com.android.support:appcompat-v7:26.0.2'
implementation 'com.android.support:design:26.0.2'

compileSdkVersion 26

注意

别忘了确保离线工作在android studio中未选中...并且您已连接到互联网

这些是无法解决依赖关系的可能原因!

【讨论】:

  • 当我同步时,Gradle 尝试从这个链接解析模块:dl-google.com/dl/maven2/com/multidots/fingerprint-auth/1.0.1/… 为什么 gradle 使用这个这个链接?我认为问题就在这里。你怎么看?
  • 因为 Gradle 试图通过链接从 maven 下载开源应用程序!! @CMaster 非常好!如果您启用了离线工作,可能会导致它!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-09
  • 2018-06-18
  • 2018-05-09
  • 2021-01-04
  • 2019-07-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多