Android Studio升级后kotlin-stdlib-jre7弃用替换报错求助
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/cachesto ensure no oldjre7artifacts 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-jre7to 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

