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

Android Studio Gradle构建报错:Failed to resolve: runtime(未用架构组件)

Fixing "Failed to resolve: runtime" Error in Android Studio (No Architecture Components Used)

Hey there, let's tackle this "Failed to resolve: runtime" error you're seeing after running a Gradle build—especially since you mentioned you aren't using any architecture components. The log snippet you shared points to a failure in the :app:compileDebugJavaWithJavac task, which usually ties back to dependency resolution issues or Gradle configuration glitches. Here are some tried-and-true fixes to get you back on track:

  • Invalidate Caches and Restart Android Studio
    Sometimes the IDE's cached data gets corrupted, leading to weird dependency resolution hiccups. Head to File > Invalidate Caches... > Invalidate and Restart to clear out stale data and give Android Studio a fresh start.

  • Audit Your app-level build.gradle Dependencies
    Even without architecture components, double-check your dependencies block for any misconfigured or outdated entries. Look for lines that might incorrectly reference a runtime artifact—make sure every dependency has a valid group, name, and version. Also, confirm your project-level build.gradle includes the necessary repositories to pull dependencies:

    repositories {
        google()
        mavenCentral()
    }
    
  • Update Gradle Plugin and Wrapper
    Outdated Gradle versions often cause compatibility issues that trigger dependency errors. In your project-level build.gradle, update the Android Gradle Plugin to the latest stable version:

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2' // Replace with the latest stable version
    }
    

    Then match it with the correct Gradle wrapper version (check the official compatibility guidelines to find the right pair). You can update this via File > Project Structure > Project or edit the gradle/wrapper/gradle-wrapper.properties file directly.

  • Clean and Rebuild Your Project
    Leftover build artifacts can sometimes mess with dependency resolution. Run Build > Clean Project first, followed by Build > Rebuild Project—this forces Gradle to re-resolve all dependencies from scratch instead of relying on cached files.

  • Dig Into the Full Gradle Sync Log
    The log snippet you shared is truncated, so check the complete Gradle sync log (found in the "Gradle" tab at the bottom of Android Studio). It should have more specific details about which runtime dependency is failing to resolve—this might even be a transitive dependency pulled in by one of your explicit dependencies, even if you aren't using architecture components directly.

  • Disable Gradle Offline Mode
    If offline mode is enabled, Gradle might be trying to use cached dependencies that no longer exist or aren't available locally. Go to File > Settings > Build, Execution, Deployment > Build Tools > Gradle and uncheck "Offline work", then sync your project again.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 07:32:21