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

Android Studio中com.android.support库版本冲突问题解决求助

解决Android Support库版本冲突问题

Hey there! No worries at all—we all start somewhere, and this is a super common headache with Android's old Support Library ecosystem. Let's fix this together.

问题根源

The red underline is telling you the truth: one of your dependencies is secretly pulling in an older version of a Support Library (specifically com.android.support:support-v13:25.3.1) while you're explicitly using 26.1.0 for others. Mixing versions can cause runtime crashes, even if your build succeeds right now.

Looking at your dependencies, the likely culprit is com.wdullaer:materialdatetimepicker:3.2.2—that version of the date picker library was built against older Support Libraries, so it's pulling in the 25.3.1 support-v13 under the hood. Adding support-v4 didn't fix it because the conflict is with support-v13, not v4.

解决步骤

1. 确认冲突来源(可选但推荐)

First, let's verify which dependency is bringing in the old library. Open Android Studio's Terminal tab and run:

  • On Mac/Linux: ./gradlew app:dependencies
  • On Windows: gradlew app:dependencies

Wait for the dependency tree to generate, then search for support-v13—you'll see exactly which library is referencing the 25.3.1 version.

2. 强制统一所有Support Library版本

The easiest way to fix this is to force Gradle to use your desired version (26.1.0) for all conflicting Support Library modules. There are two clean ways to do this:

Option A: Use Dependency Constraints (Android Gradle Plugin 3.0+)

Add this block inside your dependencies section in build.gradle (Module level):

constraints {
    implementation 'com.android.support:support-v13:26.1.0'
    implementation 'com.android.support:animated-vector-drawable:26.1.0'
    // Add any other conflicting Support Library modules here if needed
}
Option B: Force Resolution Strategy

Alternatively, you can add a global resolution rule to your build.gradle (Module level) (outside the dependencies block):

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v13:26.1.0'
        force 'com.android.support:animated-vector-drawable:26.1.0'
    }
}

3. Sync and Verify

Click "Sync Now" in Android Studio, then check if the red underline is gone. If it's still there, try File > Invalidate Caches / Restart one more time—sometimes the IDE holds onto old cache data even after a sync.

额外提示

Even though your build works now, don't ignore this warning! Mixed Support Library versions can lead to weird runtime crashes (like ClassNotFound exceptions or resource conflicts) that are hard to debug later. Fixing this now will save you headaches down the line.

内容的提问来源于stack exchange,提问作者Tom Dippé

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 09:58:56