I get the ff error when i run flutter run.
warning: [options] source value 7 is obsolete and will be removed in a future release
warning: [options] target value 7 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
error: warnings found and -Werror specified
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':connectivity:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* 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
This is my flutter doctor output:
[√] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.18362.1139], locale en-US)
• Flutter version 1.20.4 at C:\src\flutter
• Framework revision fba99f6cf9 (8 weeks ago), 2020-09-14 15:32:52 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\USER01\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\PROGRA~1\Java\jdk-13.0.2\bin\java
• Java version Java(TM) SE Runtime Environment (build 13.0.2+8)
• All Android licenses accepted.
I cant seem to find anything on google. How do i fix this error ?
This is a warning about the compiler targeting an older version of Java (7 in this case) that will be deprecated soon.
To fix this you have two options:
JAVA_HOME
to an older version of Java and then run your Flutter build. You would also need to have this JAVA_HOME
available anywhere you build from (command line, IDE, CI/CD, etc)To do option 2, update your allprojects
section of android/build.gradle
to look like the following:
allprojects {
repositories {
google()
mavenCentral()
}
tasks.withType(JavaCompile).configureEach {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(8)
}
}
}
This includes an update to change the deprecated jcenter
Maven repository.
EDIT Nov 2021: Support for toolchains has also been added to the Kotlin Gradle plugin.
https://blog.jetbrains.com/kotlin/2021/11/gradle-jvm-toolchain-support-in-the-kotlin-plugin/
Try doing this
Android Studio -> File -> Invalid cache and restart
This is not a fix but a temporary workaround. Put the following in your build.gradle
, under the allprojects{}
section:
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:-options'
}
If your Android java code is the unmodified default generated code, then the bug is with one of your dependencies, you will have to go through pubspec.yaml
and find the library that is causing the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With