java - 在 android studio 3.1.3 中集成任何库时无法解决依赖性错误

标签 java android android-studio dependencies

最近,每当我收到“无法解决 Ddependency”错误时,我都会将 android studio 更新到 3.1.3。已经被这个问题困扰了,我已经浪费了很多天来解决这个错误,但没有任何效果。请帮我解决这个错误。我已经在这里上传了我的 gradle 文件以及错误日志。

下面是我的 gradle 文件: 应用插件:'com.android.application'

android {



compileSdkVersion 27

defaultConfig {
    applicationId "com.example.administrator.myapplication1"
    minSdkVersion 15
    targetSdkVersion 27
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
`}`

`repositories {`
    `maven {`
        url "https://jitpack.io"
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.android.support:design:27.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation('com.github.ozodrukh:CircularReveal:2.0.1@aar') {
    transitive = true;
}
implementation project(':library')
api 'com.github.ozodrukh:CircularReveal:1.1.1'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
}

allprojects {
    repositories {
        jcenter()
    }
}
apply plugin: 'com.google.gms.google-services'
`

错误日志:

Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Unable to resolve dependency for ':app@debug/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details

Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details


Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details


Unable to resolve dependency for ':app@release/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details


Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp3:okhttp:3.11.0): Skipped due to earlier error
Open File
Show Details
`

项目(build.gradle):

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.0.0'

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

allprojects {
    repositories {
        google()
        jcenter()
    }
}
allprojects {
    repositories {

        maven {
            url "http://dl.bintray.com/florent37/maven"
        }
    }
}

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

最佳答案

maven {
        url "https://jitpack.io"
    }

请将此行添加到存储库下的项目级别 gradle 文件中。因为库circularReveal正在使用来自jitpack的repo。同时删除循环Reveal并重建项目,它应该能够正确构建。

项目级别 Gradle

buildscript {

repositories {
    google()
    jcenter()
    maven {
        url "https://jitpack.io"
    }
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
}
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

应用程序级别 Gradle

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.yourcomp.stackoverflow"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        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:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.android.support:design:27.1.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    implementation 'com.squareup.okhttp3:okhttp:3.11.0'
}

关于java - 在 android studio 3.1.3 中集成任何库时无法解决依赖性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51606261/

相关文章:

android - Titanium Appcelerator 可以用于 Windows 机器中的 IOS 应用程序开发吗

android - ListFragment onListItemClick - 如何知道点击了哪个组件

android-studio - 安卓工作室 : Hand Gesture Recognition fatal error: 'ext/atomicity.h' file not found

android - BarChart 上的 Int 值

java - 修改HashMap key之一

java - Java 中回调的非常具体的用法

java - Spring Boot App 打包成 jar 后不提供静态资源

java - 集群环境中数据存储在哪里?

android - Sugar ORM每次单元测试都需要保存记录?

java - 如何防止 Android Studio 使用 "Optimize imports on the fly"选项删除通配符导入