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

Android Studio升级后kotlin-stdlib-jre7弃用替换报错求助

Solution for Kotlin stdlib-jre7 to jdk7 Migration Error

Hey there, let's work through this issue you're facing after switching from kotlin-stdlib-jre7 to kotlin-stdlib-jdk7 in your Android Studio 3.1.2 + Kotlin 1.2.41 setup. The error you're seeing happens because there are still traces of the deprecated jre7 dependency lingering in your build cache or dependency tree, causing conflicts during the desugar step. Here's how to fix it:

Step 1: Clean Build Cache and Refresh Dependencies

First, let's clear out any stale cached files and force Gradle to pull fresh dependencies:

  • Open your terminal, navigate to your project root, and run:
    ./gradlew clean build --refresh-dependencies
    
  • If that doesn't do the trick, you can manually delete the Gradle cache folder at /home/ganeshtikone/.gradle/caches to ensure no old jre7 artifacts are left behind.

Step 2: Hunt Down Hidden jre7 Dependencies

It's possible a third-party library in your project is still pulling in kotlin-stdlib-jre7 indirectly. To find out which one:

  • Run this command to generate a full dependency report:
    ./gradlew app:dependencies
    
  • Search the output for kotlin-stdlib-jre7 to identify the culprit library.

Once you find it, you can force Gradle to replace all instances of jre7 with jdk7 by adding this block to your app-level build.gradle file:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'org.jetbrains.kotlin' && details.requested.name == 'kotlin-stdlib-jre7') {
            details.useTarget group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib-jdk7', version: '1.2.41'
        }
    }
}

Step 3: Sync and Rebuild Your Project

  • In Android Studio, go to File > Sync Project with Gradle Files to apply the changes.
  • Then select Build > Rebuild Project to create a fresh build without the conflicting artifacts.

This should resolve the "Unexpected inputs: ImmutableJarInput" error by ensuring all references to the deprecated jre7 library are replaced with jdk7, and no stale cache files interfere with the build process.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 09:51:14