fluttercommunity / plus_plugins

Flutter Community Plus Plugins
BSD 3-Clause "New" or "Revised" License
1.52k stars 892 forks source link

"error: invalid source release: 17" and other compilation issues #2965

Open miquelbeltran opened 1 month ago

miquelbeltran commented 1 month ago

If you are facing a compilation error similar to this:

* What went wrong:
Execution failed for task ':package_info_plus:compileDebugJavaWithJavac'.
> error: invalid source release: 17

1. Upgrade and clean project

  1. Upgrade Flutter: flutter upgrade
  2. Upgrade project dependencies: flutter pub upgrade
  3. Clean project: flutter clean
  4. Try again.

2. Check project requirements

You can find them in the packages README.md.

For example:

Check that your project is using Java 17.

Run flutter doctor -v and find the Android section, for example:

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/xyz/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /home/xyz/Android/Sdk
    • Java binary at: /snap/android-studio/155/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

3. Upgrade Android Studio

To ensure that you are using the right OpenJDK Java version, install the latest version of Android Studio, and perform a flutter clean.

4. If nothing else works:

[!NOTE] If compilation errors persist after following this guide, please search on Stack Overflow or Google before creating a new issue ticket.

  1. Check on StackOverflow: https://stackoverflow.com/search?q=error+invalid+source+release+17
  2. Check on Google: https://www.google.com/search?q=error+invalid+source+release+17
  3. Check on this issue tracker: https://github.com/fluttercommunity/plus_plugins/issues?q=error+invalid+source+release+17

If all the above fails, then create a compilation error ticket using this template: Compile Error Template

miquelbeltran commented 1 month ago

I will leave this ticket open and pinned for visibility. Any opened issues regarding this can me marked as duplicated and linked to this.