You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

求助解决Gradle依赖解析失败及配置过时警告问题

Fixing Your Gradle Warnings & Errors

Hey there! Let's tackle these Gradle issues one by one to get your project building smoothly again.

First: Resolve the Deprecation Warnings

All those warnings stem from outdated dependency configurations that Google retired back in late 2018. Here's the quick swap list to eliminate them:

  • Replace androidTestCompile with androidTestImplementation
  • Replace compile with implementation
  • Replace testCompile with testImplementation

These new configurations are more efficient and align with modern Android build practices.

Next: Fix the "Failed to Resolve" Errors

The resolution errors happen due to mismatched Firebase/Google Play Services versions, an outdated Google Services plugin, and a conflicting legacy Firebase dependency. Let's fix each issue:

  1. Upgrade Google Services Plugin: Your project uses an old plugin version that doesn't support newer Firebase SDKs.
  2. Align Firebase Versions: Mixing versions like firebase-core:15.0.0 with firebase-database:16.0.1 causes dependency conflicts—we'll sync all Firebase dependencies to matching versions.
  3. Remove Legacy Firebase Client: The old com.firebase:firebase-client-android:2.5.0 clashes with modern Firebase SDKs, and you don't need it since you're already using official Firebase libraries.

Updated App Module build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.example.alagappan.vivo"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

buildscript {
    repositories {
        google() // Add Google's repository for plugin resolution
        jcenter()
    }
    dependencies {
        classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
    }
}

dependencies {
    androidTestImplementation('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 fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    // Align all Firebase SDKs to the same version
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    testImplementation 'junit:junit:4.12'
    // Match Play Services Auth version to Firebase SDKs
    implementation 'com.google.android.gms:play-services-auth:16.0.0'
    // Update FirebaseUI to match Firebase 16.x compatibility
    implementation 'com.firebaseui:firebase-ui-database:4.1.0'
    implementation 'com.android.support:design:27.1.1'
    // Remove outdated legacy Firebase client
    implementation 'com.andkulikov:transitionseverywhere:1.7.9'
}

apply plugin: 'com.google.gms.google-services'

Updated Project-Level build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google() // Prioritize Google's repository to avoid version conflicts
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        // Upgrade Google Services plugin to support newer Firebase SDKs
        classpath 'com.google.gms:google-services:4.2.0'
    }
}

allprojects {
    repositories {
        google() // Prioritize Google's repository for dependency resolution
        jcenter()
    }
}

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

Final Steps

  1. Click the "Sync Now" button in Android Studio to apply the changes
  2. If issues persist, try cleaning the project (Build > Clean Project) then rebuilding (Build > Rebuild Project)

That should take care of all your warnings and errors!

内容的提问来源于stack exchange,提问作者Alagappan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:37:31