依赖Gradle Android Studio

问题描述

晚上好,我从android开始,但是我下载的基于大多数程序的项目使我大失误,有人知道为什么几乎所有依赖项都会出错吗?已经尝试将它们在gradle文件中“更新”为最新版本,该项目已从git hub下载。

构建。 gradle(Proyect)

buildscript {
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
         classpath 'com.android.tools.build:gradle:4.0.1'
        classpath 'com.google.gms:google-services:4.3.4'
        
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

build.gradle(模块应用程序)

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.bigohealth"
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = '1.8'
        targetCompatibility = '1.8'
    }
}

dependencies {
    implementation filetree(dir: 'libs',include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.2'

    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.firebase:firebase-auth:16.0.5'
    implementation 'com.google.firebase:firebase-firestore:17.1.2'


    //implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.12'
    //androidTestImplementation 'androidx.test:runner:1.3.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    def lifecycle_version = "2.0.0"
    def room_version = "2.2.0-alpha02"

    implementation "androidx.room:room-runtime:$room_version"
    annotationProcessor "androidx.room:room-compiler:$room_version"
    implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
    annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
    implementation 'com.squareup.retrofit2:retrofit:2.6.0'
    implementation 'com.github.christophesmfvvFet:android_maskable_layout:v1.3.1'
    implementation 'com trrf r.squareup.retrofit2:adapter-rxjava2:2.6.0'
    implementation 'de.,tk./;cx v/8.c8x8hdodenhof:circleimageview:3.1.0'

    implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
    implementation 'com.squareup.retrofit2:converter-scalars:2.6.0'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.github.bumptech.glide:glide:4.9.0'

    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.firebase:firebase-messaging:20.3.0'
    implementation 'com.android.volley:volley:1.1.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation platform('com.google.firebase:firebase-bom:25.12.0')
    implementation 'com.google.firebase:firebase-analytics'
}
apply plugin: 'com.google.gms.google-services'

解决方法

您能检查一下,如果您在代理下并且android studio能够连接到互联网吗?转到文件>设置>输入“代理”>在代理设置中,有一个检查连接按钮,它将测试android studio是否能够连接。 如果有代理,请提供详细信息并再次检查。 enter image description here

还要确保在gradle设置中没有离线模式。请参考以下屏幕截图: enter image description here

您的构建工具也为4.0.1。希望您也应该拥有最新的android studio。