[Bug]: Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20.
Platform
Android 14
Plugin
connectivity_plus
Version
6.0.3
Flutter SDK
3.24.0
Steps to reproduce
i upgraded the flutter to latest version then i ran the project and project will reproduce the same error.
Code Sample
Future<bool> hasNetwork() async {
final List<ConnectivityResult> connectivityResult =
await (Connectivity().checkConnectivity());
if (connectivityResult.contains(ConnectivityResult.mobile)) {
return true;
} else if (connectivityResult.contains(ConnectivityResult.wifi)) {
return true;
} else if (connectivityResult.contains(ConnectivityResult.none)) {
return false;
}
return false;
}
Logs
Launching lib\main.dart on sdk gphone64 x86 64 in debug mode...
Running Gradle task 'assembleDebug'...
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply
You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply
Invalid depfile: C:\Users\.dart_tool\flutter_build\012add4e11820bf67ac5ecd7d8528369\kernel_snapshot_program.d
Invalid depfile: C:\Users\.dart_tool\flutter_build\012add4e11820bf67ac5ecd7d8528369\kernel_snapshot_program.d
Invalid depfile: C:\Users\.dart_tool\flutter_build\012add4e11820bf67ac5ecd7d8528369\kernel_snapshot_program.d
Invalid depfile: C:\Users\.dart_tool\flutter_build\012add4e11820bf67ac5ecd7d8528369\kernel_snapshot_program.d
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':connectivity_plus:generateDebugRFile'.
> Could not resolve all files for configuration ':connectivity_plus:debugCompileClasspath'.
> Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20.
Required by:
project :connectivity_plus > org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.1
> Skipped due to earlier error
> Skipped due to earlier error
> Skipped due to earlier error
> Skipped due to earlier error
> Skipped due to earlier error
> Skipped due to earlier error
> Skipped due to earlier error
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 38s
Error: Gradle task assembleDebug failed with exit code 1
Flutter Doctor
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on Microsoft Windows [Version 10.0.22631.4037], locale en-US)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✗] Visual Studio - develop Windows apps
✗ Visual Studio not installed; this is necessary to develop Windows apps.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[✓] Android Studio (version 2024.1)
[✓] VS Code (version 1.92.0)
[✓] Connected device (3 available)
[✓] Network resources
! Doctor found issues in 2 categories.
Checklist before submitting a bug
- [X] I searched issues in this repository and couldn't find such bug/problem
- [X] I Google'd a solution and I couldn't find it
- [X] I searched on StackOverflow for a solution and I couldn't find it
- [X] I read the README.md file of the plugin
- [X] I'm using the latest version of the plugin
- [X] All dependencies are up to date with
flutter pub upgrade - [X] I did a
flutter clean - [X] I tried running the example project
When running ./gradlew build
Task :connectivity_plus:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':connectivity_plus:compileDebugJavaWithJavac'.
Could not resolve all files for configuration ':connectivity_plus:androidJdkImage'. Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for JdkImageTransform: /Users/abdullah/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar. > Error while executing process /Users/abdullah/Library/Java/JavaVirtualMachines/openjdk-22.0.2/Contents/Home/bin/jlink with arguments {--module-path /Users/abdullah/.gradle/caches/8.10/transforms/220a566e225b85a04fa6bc2df003361f-0e2c6523-a3ad-4115-9539-8a81a8f4e2c4/transformed/output/temp/jmod --add-modules java.base --output /Users/abdullah/.gradle/caches/8.10/transforms/220a566e225b85a04fa6bc2df003361f-0e2c6523-a3ad-4115-9539-8a81a8f4e2c4/transformed/output/jdkImage --disable-plugin system-modules}
The ticket is missing the complete flutter doctor -v report. flutter doctor is not enough, you have to run it with the -v option.
This doesn't look like a plugin bug but a configuration issue in your project.
Searching for Could not resolve org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.20. suggests for the following solution: https://stackoverflow.com/a/57025919
You can also paste here your gradle files maybe someone can spot an issue in them.
When running ./gradlew build
Task :connectivity_plus:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':connectivity_plus:compileDebugJavaWithJavac'.
Could not resolve all files for configuration ':connectivity_plus:androidJdkImage'. Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
Execution failed for JdkImageTransform: /Users/abdullah/Library/Android/sdk/platforms/android-34/core-for-system-modules.jar. Error while executing process /Users/abdullah/Library/Java/JavaVirtualMachines/openjdk-22.0.2/Contents/Home/bin/jlink with arguments {--module-path /Users/abdullah/.gradle/caches/8.10/transforms/220a566e225b85a04fa6bc2df003361f-0e2c6523-a3ad-4115-9539-8a81a8f4e2c4/transformed/output/temp/jmod --add-modules java.base --output /Users/abdullah/.gradle/caches/8.10/transforms/220a566e225b85a04fa6bc2df003361f-0e2c6523-a3ad-4115-9539-8a81a8f4e2c4/transformed/output/jdkImage --disable-plugin system-modules}
Had this problem with Android Studio (version 2024.2) After downgrading it to 2024.1 problem was gone.
You need to upgrade dependencies if you want to use the latest Android Studio with Java SDK 21, there is now in the pinned ticket #3303