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

打开项目时无法安装constraint-layout:1.0.2,报错Failed to resolve

Fixes for "Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2"

Hey, I’ve dealt with this exact error a few times when working on older Android projects—let’s go through the most reliable fixes to get that constraint-layout dependency resolved:

  • Verify your project-level build.gradle has the right repositories
    Older versions of the support library-based Constraint Layout (like 1.0.2) are hosted on Google’s Maven repository, not just Maven Central. Double-check that your project-level build.gradle includes both repositories in the repositories blocks:

    buildscript {
        repositories {
            google()
            mavenCentral()
        }
        // Keep your existing buildscript dependencies here
    }
    
    allprojects {
        repositories {
            google()
            mavenCentral()
        }
    }
    

    Note: If you’re using an ancient Android Studio version (pre-3.0), replace google() with maven { url 'https://maven.google.com' } since the shorthand wasn’t available back then.

  • Update to a newer compatible version (recommended)
    Version 1.0.2 is really outdated—sometimes older library versions get archived or moved in repositories, making them hard to pull. If your project allows it, switch to a more recent 1.x stable release (like 1.1.3, the last of the 1.x line) or migrate to the AndroidX version if you’ve already adopted AndroidX.

    For AndroidX, first confirm these lines are in your gradle.properties:

    android.useAndroidX=true
    android.enableJetifier=true
    

    Then update your app-level build.gradle dependency to:

    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    
  • Invalidate Android Studio’s caches and restart
    Corrupted cache files often cause false dependency resolution errors. Head to File > Invalidate Caches..., select "Invalidate and Restart", and let Studio refresh its cached repository data. This fixes a surprising number of these "failed to resolve" issues.

  • Check network and proxy settings
    If you’re on a corporate network or using a proxy, Android Studio might be blocked from accessing Google’s Maven repo. Go to File > Settings > Appearance & Behavior > System Settings > HTTP Proxy to verify your proxy configuration is correct. You can also try switching to a personal network temporarily to rule out connectivity problems.

  • Manually add the library (last resort)
    If all else fails, you can download the AAR file for constraint-layout:1.0.2 and add it as a local dependency:

    1. Create a libs folder in your app module if it doesn’t exist.
    2. Drop the downloaded AAR into libs.
    3. Add this to your app-level build.gradle:
      repositories {
          flatDir {
              dirs 'libs'
          }
      }
      
      implementation(name: 'constraint-layout-1.0.2', ext: 'aar')
      

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 04:49:19