[Android SDK cmdline-tools] Warning: Could not create settings while installing SDK from the terminal in Ubuntu

I had to Install Android SDK version 28 for installing Flutter. For that I downloaded the zipped package of Android SDK from android studio website.

Link: https://developer.android.com/studio/index.html#download

I didn’t want to install Android Studio but my plan was to use Visual Studio Code as the IDE. I unpacked the Android SDK and extracted it in my home folder. But while I wanted to see the list of packages available in android sdk it always showed my the following error:

Warning: Could not create settings
java.lang.IllegalArgumentException
    at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)

Warning: Could not create settings

In order to resolve this issue first we need to create a folder called cmdline-tools. You can create in any destination. After creating the folder move your tools folder which is the Android-SDK package you have downloaded from above link.

mkdir cmdline-tools
mv tools cmdline-tools/tools

After moving the package to cmdline-tools directory make open your .bashrc file and add the following configuration:

#First In your terminal type:
nano ~/.bashrc
# Second Add the following configuration:
export PATH="$HOME/cmdline-tools/tools:$HOME/cmdline-tools/tools/bin:$PATH"

Now close the file saving the changes you just made. Then compile the bashrc file with this command:

source ~/.bashrc

After that when you type sdkm and press tab key you will see the sdkmanager command on your terminal.

THan you can check the packages of SDK and build tools available in your SDK Manager with this command:

sdkmanager --list

Since flutter requires SDK version 28 it can be downloaded using the following command:

sdkmanager "platform-tools" "platforms;android-28"