无法解析我依赖项中的所有库

时间:2018-10-15 15:12:17

标签: android gradle build.gradle

由于某种原因,我只是删除了.gradle / caches文件夹并重新下载了所有库,下载完成后,我只是清理并重建了,但是gradle无法构建,并且所有库都无法解决错误。我将.gradle / caches重新带回了第一次,但没有任何变化。我尝试使cach或gradle脱机工作无效,但未解决。这发生在所有项目中

请帮助。谢谢

enter image description here

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.dibapc.alopackage"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 4
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        manifestPlaceholders = [onesignal_app_id               : "xxxx",
                                onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    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:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    compile 'com.android.support:recyclerview-v7:27.1.1'
    compile 'com.android.support:cardview-v7:27.1.1'
    compile 'com.github.bumptech.glide:glide:4.5.0'
    implementation 'com.android.support:design:27.1.1'
    compile 'com.github.myinnos:ImageSliderWithSwipes:1.0.2'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.android.volley:volley:1.1.1'
    implementation 'com.github.apl-devs:appintro:v4.2.3'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    compile 'com.onesignal:OneSignal:3.9.2@aar'
    compile 'com.google.android.gms:play-services-gcm:11.0.4'
    compile "com.google.android.gms:play-services-location:11.0.4"
    implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.3.0'
    implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.6.0'
    implementation 'com.github.florent37:runtime-permission:1.0.0'
    compile 'com.flaviofaria:kenburnsview:1.0.7'
    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'
}

build.gradle

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

buildscript {

    repositories {
        mavenCentral()
        google()
        jcenter()
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    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 {
        maven { url "https://jitpack.io" }
        maven { url 'https://maven.google.com' }
        google()
        jcenter()
        mavenCentral()
    }
}

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

1 个答案:

答案 0 :(得分:0)

首先,从现在开始使用implementation而不是compile。即:

implementation 'com.android.support:recyclerview-v7:27.1.1'

第二,如果您删除了缓存,则需要再次下载所有内容,因此,在您的情况下,更改IP将解决问题,然后进行清理项目并取消选中 Offline work下载来自互联网的所需文件。

如果这样做没有帮助,请尝试将它们添加到您的build.gradle存储库中:

 repositories {
        google()
        jcenter { url "http://jcenter.bintray.com/" }
        mavenCentral()
        maven {
            url "https://jitpack.io"
        }

最后,将您的gradle更新为:

classpath 'com.android.tools.build:gradle:3.2.1'