How to change the path for Flutter SDK - Linux - android

So far I have downloaded two different version for the flutter SDK.
One is v2.10.2 and another is v2.5.3.
Currently Flutter is installed in my Linux system with v2.10.2 but the version 2.5.3 is required to run the old flutter project.
So, I required to downgrade the flutter version. So, How can I change the Path for the flutter SDK from terminal ?
I have tried below way :
export PATH="$PATH:/home/jaiminmodi/snap/flutter/common/v2.5.3/flutter_linux_2.5.3-stable/flutter/bin"
But still while checking flutter version its showing 2.10.0
What might be the issue ? Thanks.

I suggest you to use fvm
https://fvm.app/docs/getting_started/installation
It'll take care of everything you just need to set it up.

I can help you with windows. I don't have prior knowledge in Linux but looking at windows procedure you will understand something.
First, download both v2.10.2 and v2.5.3 zip files and extract them in a folder like the following for v2.10.2 its name flutter, and for v2.5.3 its name flutter253.
In my case, I have two versions latest and v1.22.6.
Now create one folder named aliases.
Create two batch windows files named flutter and flutter253.
In my case, it's flutter and flutter1226.
Now edit both files using notepad and add the following line.
for the latest version add code (Add your latest flutter version bin path)
#echo off
D:\"Program files"\flutter\bin\flutter %*
for another version add the following code (Add your v2.5.3 flutter version bin path in my case it was v1.22.6 means flutter1226 folder bin path you will be flutter253)
#echo off
D:\"Program files"\flutter1226\bin\flutter %*
Now add aliases folder path in your user and system path environment variables like the following (I highlighted the image)
1. User
2. System
Congrats! it's done now you can you both versions by running commands like
flutter --version and
flutter253 --version in my case it's flutter1226 --version
Now to add it's in your vscode do as the following image
1. go to settings and search dart SDK
2. by clicking the flutter version below you can change the SDK version.

Related

can I use flutter without downloading android studio?

I was just wondering if I can use flutter without downloading Android studio because Android Studio is very heavy
You can do so, by following the below steps.
Note: The sum of all the downloaded files is about 1.5GB including VS Code.
Download and install VS Code 88MB.
Install the Flutter extension, which automatically installs the Dart extension.
Download the Flutter SDK 818MB. Extract to C:\Flutter.
Download the Android Command Line Tools 115MB. Extract to C:\Android\cmdline-tools.
Download the Android Platform Tools 5MB. Extract to C:\Android\platform-tools.
Download the Java SDK (version 17 or lower) 171MB. Extract to C:\Java.
In Environment Variables edit the Path system variable and add the following:
%SYSTEMDRIVE%\Android\platform-tools +
%SYSTEMDRIVE%\Android\cmdline-tools\bin +
%SYSTEMDRIVE%\Flutter\bin +
%SYSTEMDRIVE%\Java\bin.
In Environment Variables add the following new system variables.
Name: JAVA_HOME. Value: C:\Java.
Name: ANDROID_HOME. Value: C:\Android\cmdline-tools.
Name: ANDROID_SDK_ROOT. Value: C:\Android\cmdline-tools.
Run the following command as administrator: sdkmanager --licenses, and accept all the licenses.
In phone's settings, enable Developer options and USB debugging, also enable the Developer mode on your PC.
Connect your phone and make sure that all drivers are installed.
Create a new flutter project and run it using the command flutter run. This will download the needed files (automatically) to run the app on your phone and create an APK file. Download size is about 300MB.
You can use Visual Studio Code or Emacs Link
You can still code, but it won't compile, since Flutter SDK needs the Gradle and other tools(that comes with android studio) to be compiled and run in Android, and the flutter doctor in the command line will complain too and won't let you do much.
Yes you can, you want to download VSCode and get the dart & flutter extensions in it, but you need AVD which is provided with Android Studio to run your applications or you can use any other emulator.
Needless to say you also need the Flutter SDK.
You could try https://dartpad.dev/flutter if you're not planning anything big. It's a flutter version of the dart playground and it lets you test some flutter features, but (as far as I know) it's limited to one file only. And you won't be able to use 3rd party libraries too.

Sdkmanager "Error: Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli" on Windows

I am trying to install Flutter without Android Studio and here is what I did:
Installed Java 8
Installed and Unzipped Flutter SDK to C:\src.
Installed and Unzipped Android Command-line tools (sdkmanager) to C:\Android.
Added the environment variables (ANDROID_HOME: C:\Android)
Now when I try to run sdkmanager to install Android SDK, I get this error:
"Error: Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli"
I have tried reinstalling Flutter sdk and the sdkmanager with no luck.
Here is Flutter Doctor's output:
sdkmanager error:
Open the sdkmanager.bat in a text editor and add echo %CLASSPATH% just below the CLASSPATH=%APP_HOME%\...\sdkmanager-classpath.jar. Then run sdkmanager --help which will echo the CLASSPATH of the required file. And check whether is it the valid path.
In my case, it was the wrong path,
It said my sdkmanger-classpath.jar is in lib folder. But it was not! It was actually inside the lib/_ folder. So as the simple solution what I did was copy the content in side lib/_ folder to lib. Then it worked fine!
Download the SDK tools ZIP (Under Command Line Tools in https://developer.android.com/studio).
Unzip using 7zip. Avoid using the default windows extractor - that doesn't do the extraction correctly.
After unzipping using 7zip, place the contents into the sdk folder (C:\Users\<username>\AppData\Local\Android\Sdk\tools\bin and C:\Users\<username>\AppData\Local\Android\Sdk\lib) and run sdkmanager on command prompt.
On Windows Server 2019, using commandlinetools-win-6609375_latest.zip, we faced the same issue. We placed package inside Program File (i.e. C:\Program Files\Android\cmdline-tools\tools\bin).
It seems this will not work if there is space in the path. So we placed it in folder path without spaces (i.e. C:\Android\cmdline-tools\tools\bin) and it is working fine!🎉
As #Chrishan wrote Avoid using default windows extractor.
You can use the PowerShell:
Expand-Archive commandlinetools....zip C:\Android\Sdk
It worked for me.
Make sure there exists no space in the path folders in the path to SDK.
example: C:\Users\Anu Jadav\xyz\
like above in username I had space, Initially, I was not able to execute flutter doctor --android-licenses.
After I renamed the username. Then it worked like a charm.
I renamed my username using this reference video
.
Go to android sdk folder.
Open cmdline-tools folder.
Then rename "latest" folder as "tools".
Default name:
(Path to sdk)\AndroidSDK\cmdline-tools\latest
After rename:
(Path to sdk)\AndroidSDK\cmdline-tools\tools
Then;
run flutter doctor command using terminal.
I fixed by adding '--sdkroot ' pointing to the root folder (i.e. parent of bin).
e.g. % ./bin/sdkamanager --sdkroot .
I have solved this issue by doing so many things.
Download Java 8.
Set EV to the Java 8 folder.
Download SDK in separate folder.
While setting EV of SDK make it sure there is no whitespace in the path.
Set path of the following in user variables:
Build-tools.
platform-tools.
platform
Now enter flutter doctor --android-licenses
press y multiple times and at last your licenses will be accepted.
Check whether your license accepted or not by using flutter doctor
Firstly open android studio and from there open sdk manager and install required sdk tools then -
Make sure there exist no space in the path folders in the path to sdk.
Add ANDROID_SDK_ROOT variable to the Users variable with value as the path for sdk folder e.g. C:\users\xyz\android\sdk (there should be no space in these folder names).
Add this path to the path variable in the system variable.
Run flutter doctor in the command prompt.
Run flutter doctor --android-licenses.
Accept the licenses by entering 'y'.
--The setup should be done and just check by running flutter doctor.
I fixed this issue by removing a space in my path where i had extracted the cmd tools.
My path was:
C:\Cordova Tools\cmdline-tools
there was a space in folder name "Cordova Tools".
I removed the space and changed folder name like:
C:\Cordova_Tools\cmdline-tools
And it worked just perfectly.
The problem may be due to the fact that your sdk installation failed severally before finally installing.
To check if that is the case, go the path C:\Users<username>\AppData\Local\Android\Sdk and if there are tools, tools-1, ...
The necessary files are installed in the last of this folder.
So, rename the supposed original folder - tools, to something else and change the name of the one in which the installation is done to tools.
This should solve the problem.
download jdk 11
and update ev JAVA_HOME to C:\Program Files\Java\jdk-11.0.17

How to fix 'Android SDK not found at this location' error while installing flutter?

I'm installing flutter in my Ubuntu 18.10. I'll be using Visual Studio Code for flutter development. I've not installed Android Studio.
I've downloaded Android Command line tools from official android site and extracted it in a separate folder in Documents/development/android
I set the path for ANDROID_HOME in the bashrc file by following the flutter documentation
Here is the .bashrc file
And the Android toolchain error
It seems that , you set the ANDROID_HOME variable but it is not added to PATH.
Make sure you add the ANDROID_HOME to the path as below
export PATH=$PATH:$ANDROID_HOME/bin
and re-launch the console.
update
In order for Android SDK to work fine, you need to set path for the below SDK packages.
..android-sdk\tools
..android-sdk\platform-tools
and your ANDROID_HOME will be
..android-sdk
I am not sure what you are referring to when you are saying that you have downloaded Android Command Line tools. From the output in your terminal, it tells me that you do not have the SDK files in your machine. To download the Android SDK, please see this link here and download the tar file that matches your operating system. Then extract the tar file in the folder which you have set as ANDROID_HOME. This should work fine.
In case you are having the same error, I strongly recommend downloading the Android Studio and install the Android SDK through the Android Studio. The flutter documentation says so as well. You can always uninstall or remove Android Studio after it is being installed and if you are not considering using it.
please replace yout android sdk in thatway this is default installation location of sdk C:\Users\Intel\AppData\Local\android\android_sdk

Unable to locate the Android SDK

I already had Android Studio and the Android SDK installed. I later added Flutter and the Flutter SDK. Here is my problem: When I run
flutter doctor
It shows,
that I do not have the Android SDK installed.
You can configure the Android SDK for your project using
flutter config --android-sdk /path/to/android/sdk
The PATH variable also should contain the SDK, like
export PATH=$PATH:/usr/local/opt/android-sdk/emulator:/usr/local/opt/android-sdk/build-tools/26.0.1:/usr/local/opt/android-sdk/platform-tools:/usr/local/opt/android-sdk/tools
/usr/local/opt/android-sdk and 26.0.1 might not match your system. That's just an example.
Step-by-step guidance for Windows with pictures
Step 1.
If you see this error, it means Flutter does not locate your Android SDK.
There are two folders containing all files of the "Android SDK". They are "Platform" and "Platform Tools":
Those folders are located in my computer here:
C:\Users\ZohaibSaleem\AppData\Local\Android\Sdk
(My name is Zohaib Saleem, and you should replace my username folder name with your computer username.)
Step 2
Type "Env" in the search bar of Windows
Click on "System Variable Environment"
Click on "Advanced and Environment Variable"
Go to System Variable → Path → Edit:
Now paste the path of both folder "platform" and "platform-tools", respectively.
In my case, the paths are:
C:\Users\ZohaibSaleem\AppData\Local\Android\Sdk\platforms
C:\Users\ZohaibSaleem\AppData\Local\Android\Sdk\platform-tools
After adding the path to your System variable it looks like:
Click OK
Restart PowerShell and again run the command "flutter doctor".
Now, the Android SDK problem is resolved, but you faced another problem:
To resolve this issue, just run the command
flutter doctor --android-licenses
And accept all with "Y". At the end, after typing multiple 'Y's, again run 'flutter doctor' and all is set!
flutter config --android-sdk /your path
example
flutter config --android-sdk /root/Android/Sdk
Tools > SDK Manager > Android SDK
images
Locate the Android SDK folder (e.g., D:\SDK).
Add platforms (D:\SDK\platforms) and platform-tools (D:\SDK\platform-tools) to the PATH variable.
Run flutter doctor. It should not show any errors or warnings.
For this issue you have to add three variables to the Path in the:
C:\Users\admin\AppData\Local\Android\platforms // The path to
platform
C:\Users\admin\AppData\Local\Android\platform-tools //
The path to platform-tool
C:\Users\Admin\AppData\Local\Android\emulator // The path to
emulator

How to add android to cordova platform? PATH error?

I am trying to add android as a cordova platform so that I can build apps with phonegap. When I tried to add android thus:
$ cordova platform add android
I received this error message:
[Error: The command android failed. Make sure you have the latest
Android SDK installed, and the android command (inside the tools/
folder) added to your path. Output: /bin/sh: android: command not
found ]
I do have the latest Android SDK installed, so I suppose I need to add android to my path. I've googled on how to do that, and searched this forum, but I have little knowledge of command line use and I don't understand the answers.
If someone could provide very simple steps to add android to my path, I would be most grateful.
There's step-by-step instructions on the PhoneGap Doc's. Check it out here, and then go to Step 3B. I linked to the 2.8 version of PhoneGap since from a quick look it doesn't seem to explain how to set up PATH on the 3.0 version docs.
I just figured this out. You need to use the path where your android tools are actually installed. Mine happen to be in the default location (and I'm using x64) so, /Applications/adtbundle name/
Just see for yourself!
I was running into a rather silly problem here. The path that I cut and pasted had the adt-bundle listed as "adt-bundle" (as one might expect :)) but I never changed the name of the directory as it was downloaded, which was "adt-bundle-mac-x86_64-20131030."
Additionally, the path ($PATH) that I cut and pasted into my .bash_profile began with "/Development" when it should have begun with "~/Development" since the Development directory was in my home directory.
I don't know if anyone else might find this info useful, but it was a relief to me when I realized that I just needed to correct the paths I'd specified in .bash_profile.
Its very easy. Just Download the android SDK, later set the path android sdk having folder tools and platforms tools in the system variables. Now later the set the path of ANDROID_HOME in the user variable. That's it. Now you can add, run , build your android platform.
On MAC - I got this problem after installing Android Studio (it was working before).
I had to do:
touch ~/.bash_profile; open ~/.bash_profile
and then add the line
export PATH=$PATH:/Users/<USR>/Library/Android/sdk/tools
and restart terminal.
If you used Eclipse to install and manage Android SDK then do following:
Open Window->Android SDK Manager in Eclipse and in new window you will be able to see SDK Path on the top
Now you should include this path as ANDROID_HOME system variable and export /tools and /build-tools it to system PATH variable
On OS X you can include system variables like following:
In Terminal run nano ~/.bash_profile (because probably the .bash profile is not create yet, it will we created in root folder of your User)
In my case SDK path was '/Users/markusila/android-sdks'
Insert following code, but using your SDK path, into the editor opened
export ANDROID_HOME=/Users/YOUR_USER_NAME/android-sdks
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Now simply run . ~/.bash_profile and changes will be included.
In addition to the answers above, don't forget to update the file based in your favorite shell, for example:
ZSH:
1. vi ~/.zshrc
2. Considering that my Android SDK is in "/Users/wils/Library/Android/sdk/" and using vi as editor:
export PATH="/Users/wils/Library/Android/sdk/platform-tools:/Users/wils/Library/Android/sdk/tools:$PATH"
3. Save
4. source ~/.zshrc
BASH:
1. vi ~/.bash_profile
2. Considering that my Android SDK is in "/Users/wils/Library/Android/sdk/" and using vi as editor:
export PATH="/Users/wils/Library/Android/sdk/platform-tools:/Users/wils/Library/Android/sdk/tools:$PATH"
3. Save
4. source ~/.bash_profile
I hope it help somebody else.
Piece \o/

Categories

Resources