Gradle 错误 - 无法下载 okhttp.jar 文件 2.7.2

2023-12-27

当我添加 firebase 函数库时(实现“com.google.firebase:firebase-functions:16.1.0”),android studio(3.1.4) 抛出“无法解析“:app@debug/compileClasspath”的依赖关系:无法下载 okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)"

我尝试添加“实现文件('libs/okhttp-2.7.2.jar')“但仍然遇到同样的错误。

这是我的 build.gradle(应用程序)

apply plugin: 'com.android.application'  

android {    
    compileSdkVersion 27  
    buildToolsVersion '27.0.3'  
    defaultConfig {  
        applicationId "com.caliber.mskhan.calibergaming"  
        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.1'  
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'  
    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 'com.android.support:design:27.1.1'  
    implementation 'de.hdodenhof:circleimageview:2.1.0'  
    implementation 'com.google.android.gms:play-services-maps:15.0.1'  
    implementation 'com.google.android.gms:play-services-location:15.0.1'  
    implementation 'com.google.maps.android:android-maps-utils:0.5'  
    implementation 'com.squareup.picasso:picasso:2.5.2'  
    implementation 'com.github.clans:fab:1.6.4'  
    implementation 'com.github.bumptech.glide:glide:3.7.0'  
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'  
    implementation 'com.android.support:cardview-v7:27.1.1'  
    implementation 'com.android.support:recyclerview-v7:27.1.1'  
    implementation 'com.google.firebase:firebase-auth:16.0.3'  
    implementation 'com.google.firebase:firebase-database:16.0.1'  
    implementation 'com.google.firebase:firebase-storage:16.0.1'  
    implementation 'com.google.firebase:firebase-messaging:17.3.0'  
    implementation 'com.google.firebase:firebase-functions:16.1.0'  
    implementation 'com.google.firebase:firebase-core:16.0.1'  
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.3.1'  
    implementation 'com.android.volley:volley:1.1.0'  
    implementation 'com.karumi:dexter:4.2.0'  

    //implementation files('libs/okhttp-2.7.2.jar')  
}  
apply plugin: 'com.google.gms.google-services'  

这是我的 build.gradle(项目)

buildscript {

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

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

        classpath 'com.google.gms:google-services:4.0.1'
    }
}

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

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

gradle 同步后构建错误 https://i.stack.imgur.com/eRM4y.jpg


Change this 


// 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.4'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'com.google.firebase:firebase-plugins:1.0.4'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Gradle 错误 - 无法下载 okhttp.jar 文件 2.7.2 的相关文章

随机推荐