Flutter java version

Flutter Java Version

Flutter uses the Dart programming language for developing mobile applications. However, you can also write platform-specific code using Java for Android integration in your Flutter app. The Java version used in Flutter depends on the Android Gradle plugin version and the Android SDK you have installed.

1. Android Gradle Plugin Version

The Java version used in your Flutter app is determined by the Android Gradle Plugin version specified in your Flutter project’s android/build.gradle file. Locate the dependencies block and check for the following line:

classpath 'com.android.tools.build:gradle:x.x.x'

The version number x.x.x represents the Android Gradle Plugin version. You can find the corresponding Java version mappings in the official Android Gradle Plugin documentation.

2. Android SDK

The Java version used by the Android SDK depends on the compileSdkVersion and targetSdkVersion settings in your Flutter project’s android/app/build.gradle file. Locate the android block and check for the following lines:

compileSdkVersion x
targetSdkVersion x

The version numbers x represent the Android SDK versions. Different Android SDK versions use specific Java versions for compilation.

Examples

Let’s consider two examples:

Example 1

android/build.gradle:

classpath 'com.android.tools.build:gradle:4.1.0'

android/app/build.gradle:

compileSdkVersion 30
targetSdkVersion 30

In this example, with Android Gradle Plugin version 4.1.0 and compile/target SDK version 30, the corresponding Java version would be Java 11.

Example 2

android/build.gradle:

classpath 'com.android.tools.build:gradle:3.6.4'

android/app/build.gradle:

compileSdkVersion 29
targetSdkVersion 29

In this example, with Android Gradle Plugin version 3.6.4 and compile/target SDK version 29, the corresponding Java version would be Java 8.

Remember, these examples are just for illustration purposes, and the actual Java version may differ based on your setup.

Leave a comment