What to do if your Android toolchain is partially installed

Beginning Flutter with Dart
Beginning Flutter with Dart

Get more free books at https://leanpub.com/u/sanjibsinha

For more Flutter related tutorials visit : ZeroDotOne

https://zerodotone.net/why-is-state-management-in-flutter-what-is-flutter-state/

While creating a new flutter application through Ubuntu terminal, you may have encountered this type of message:

All done!
[✓] Flutter: is fully installed. (Channel stable, v1.17.4, on Linux, locale
en_IN)
[!] Android toolchain - develop for Android devices: is partially installed;
more components are available. (Android SDK version 30.0.0)
[✓] Android Studio: is fully installed. (version 4.0)
[!] Connected device: is not available.

Run “flutter doctor” for information about installing additional components.

In order to run your application, type:

$ cd basic_layout_app
$ flutter run

Your application code is in basic_layout_app/lib/main.dart.

https://zerodotone.net/what-is-inherited-widget-in-flutter-how-do-you-use-state-management/

Your flutter app has been created. But, there is a small problem with your Android toolchain. It is partially installed. Why this happens? It happens, because your JAVA_HOME variable in your environment does not match with the location of your Java installation. It may have happened for several reasons.

To solve the problem as quickly as possible, we can do one thing. We should set, the JAVA_HOME path, correctly, to the valid directory.

If we run another command like below:

flutter doctor --android-licenses

We get the same output that clearly mentioned the problem.

ERROR: JAVA_HOME is set to an invalid directory: /usr/bin/java

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

To rectify the problem, we should know the JAVA_HOME path. To know that issue this command:

readlink -f $(which java)

It will give you the correct path, as the following output:

/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

Now, we know the correct path, we should set JAVA_HOME to the correct path now by issuing this command:

export JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/"

You have probably noticed that I have omitted the last part of the path: “bin/java”.

That is all! Now you run the ‘flutter doctor’ command again. The output will greet you with no error!

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.4, on Linux, locale en_IN)

[✓] Android toolchain – develop for Android devices (Android SDK version 30.0.0)
[✓] Android Studio (version 4.0)
[!] Connected device
! No devices available

! Doctor found issues in 1 category.
ss@ss-desktop:~/Documents/development/basic_layout_app$

Now, your Android toolchain is fully installed. Moreover, your JAVA_HOME path is also set to the correct path.

Happy coding!