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

添加Firebase后Android Studio提示support库版本不一致问题求助

Fixing Android Support Library Version Mismatch (27.1.1 vs 26.1.0)

Hey there! That version mismatch error is super common when using third-party libraries that pull in older support library versions under the hood. In your case, the com.google.firebase:firebase-core:15.0.0 dependency is indirectly bringing in the 26.1.0 version of some support libraries, which clashes with your explicitly declared 27.1.1 version. Here are a few solid ways to fix this:

1. Force All Support Libraries to Use a Single Version

The quickest fix is to add a configuration rule that forces every support library dependency — direct or indirect — to use your desired version. Just drop this block inside the android section of your app-level build.gradle file:

android {
    // ... your existing android configuration (compileSdkVersion, defaultConfig, etc.)

    configurations.all {
        resolutionStrategy {
            force 'com.android.support:support-media-compat:27.1.1'
            force 'com.android.support:animated-vector-drawable:27.1.1'
            // Add other flagged support libraries here if the error expands
        }
    }
}

This tells Gradle to ignore any conflicting versions pulled in by other libraries and use 27.1.1 for the specified support artifacts.

2. Exclude the Conflicting Dependency Directly

If you want to target the root cause, first run this command in your project root terminal to see the full dependency tree:

./gradlew app:dependencies

You’ll find com.android.support:support-media-compat:26.1.0 listed under the com.google.firebase:firebase-core:15.0.0 branch. Once confirmed, exclude that old dependency directly from Firebase in your dependencies block:

implementation('com.google.firebase:firebase-core:15.0.0') {
    exclude group: 'com.android.support', module: 'support-media-compat'
}

Your project will then fall back to the 27.1.1 version you declared explicitly.

3. Upgrade Firebase to a Compatible Version (Optional)

Firebase versions often align with specific support library versions. If you’re open to updating Firebase, look for a firebase-core version that naturally uses 27.1.1 or later. Keep in mind this might require updating other Firebase dependencies too, so it’s a more involved change than the first two options.

Final Check

After making any of these changes, sync your project with Gradle (click the "Sync Now" button in Android Studio) and the mismatch error should vanish. Also, double-check that your targetSdkVersion in build.gradle is set to 27 to match your support library version — this avoids additional compatibility warnings.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 03:53:16