0

I am using flutter version 2.2.2 and the latest android studio for the moment. I have a Flutter project that worked fine few months ago, but now - after upgrading flutter and dart - it does not run.

I tried downgrading flutter and dart, but kept getting the same error when running:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':firebase_core:compileDebugJavaWithJavac'.
> java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0

* 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 18s
Exception: Gradle task assembleDebug failed with exit code 1

I have this pubspec.yaml dependencies:

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  http: ^0.12.2
  email_validator: '^1.0.5'
  path_provider: ^1.6.18
  social_share: ^2.0.5
  firebase_admob: ^0.10.2

I tried changing firebase_admob to google_mobile_ads but that did not solve the problem either.

I am already using AndroidX.

Can any body see a problem? Does anybody have a possible solution? Thanks!

1 Answer 1

1

The problem was with the JAVA DEVELOPMENT KIT version. I changed it to version 11.0.11 and it worked just fine. To do that, download the right JDK and change the JAVA_HOME environment variable.

IMPORTANT: a Java version too new might not work as well. Version 11 should be fine (and 8 as others over the internet stated).

Sign up to request clarification or add additional context in comments.

2 Comments

So, I should register JAVA_HOME variable inside ~/.zshrc file right? And also run source ~/.zshrc to reflect the changes, right? Btw, I'm using Zsh.
It does not matter how you change the env variable, but the way you mentioned is supposed to work just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.