- download flutter
git clone -b master --depth 1 https://github.com/flutter/flutter.git
- update environment variables
You can only update the PATH variable for the current session at the command line, as shown in the Clone Flutter repo. However, what you may want is to permanently update this variable so that you can run flutter
commands in any terminal session.
The steps to permanently modify this variable for all terminal sessions are computer system specific. Typically you would add commands that set environment variables to the file that is executed when opening a new window. For example
-
Identify the directory of your Flutter SDK, which you will use in step 3.
-
Open (or create)
$HOME/.bash_profile
. The file path and filename may be different on your machine. -
Add the following line and change
[PATH_TO_FLUTTER_GIT_DIRECTORY]
to the path where you cloned Flutter’s git repo:Add in
~/.bash_profile
, if there is no.bash_profile
, executevim ~/.bash_profile
add.bash_profile
> filesexport PUB_HOSTED_URL=https://pub.flutter-io.cn #Domestic users need to set export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn #Domestic users need to set export PATH=PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH
Note:
PATH_TO_FLUTTER_GIT_DIRECTORY
is the path of your flutter, such as “~/document/code”export PATH=~/document/code/flutter/bin:$PATH
-
Run
source $HOME/.bash_profile
to refresh the current terminal window.Note: If you are using zsh,
~/.bash_profile
will not be loaded when the terminal starts. The solution is to modify~/.zshrc
and add:source ~/.bash_profile
-
Verify that the directory is already in the PATH by running the flutter/bin command:
echo $PATH
.bash_profile
final configuration:
export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn export PATH=~/Documents/FlutterWorkspces/flutter/bin:$PATH export JAVA_HOME=~/Library/Java/JavaVirtualMachines/openjdk-20.0.1/Contents/Home export PATH=$JAVA_HOME/bin:$PATH:. export CLASS_PATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
Download java JDK
Official website: https://www.oracle.com/java/technologies/downloads/
- Note system ARM or x64
Download in Android Studio (recommended):
Add JAVA environment
export JAVA_HOME=~/Library/Java/JavaVirtualMachines/openjdk-16.0.1/Contents/Home export PATH=$JAVA_HOME/bin:$PATH export CLASS_PATH=$JAVA_HOME/lib
flutter doctor success
Some errors reported by flutter doctor
Android sdkmanager tool not found
javax.xml.bind.annotation.XmlSchema
Exception in thread “main” java.lang.NoClassDefFoundErro
Solution steps:
Literally, the problem should be in “/Users/xx/android-sdk/tools/bin/sdkmanager”, but I tried it and found that there is no Tools folder under the root SDK folder
Baidu searched around, and the solutions given on the Internet are to move the sdkmanager in the emulator directory to the tools directory, but I don’t have this folder at all.
Later, I found the reason on Stack Overflow: In the latest version of Android Studio, the Android SDK Tools are not installed by default, and my version is 3.6.
Find the reason and solve it:
- Find SDKTools in the andriod studio-preferences in the upper left corner of the window
-
Remember to click OK to confirm
Continue to execute in the terminal
flutter doctor –android-licenses
Then just choose Y all the way
PS: Both VScode and AS must remember to install the flutter plugin, and AS must also install the dart plugin
Android Studio Unable to find bundled Java version solution
solution:
- If it is a macOS system, create a jre directory in the same directory as jbr, and then copy all the files in the jbr directory to the jre directory. Create a new jdk folder under the jre file, and put the contents here under the jdk folder
- If it is a Windows system, the jre directory exists, but there is almost nothing in it, you can directly copy all the files in the jbr directory to the jre directory.
Last
If you want to become an architect or want to break through the 20-30K salary range, then don’t be limited to coding and business, but you must be able to select models, expand, and improve programming thinking. In addition, a good career plan is also very important, and the habit of learning is very important, but the most important thing is to be able to persevere. Any plan that cannot be implemented consistently is empty talk.
If you have no direction, here I would like to share with you a set of “Advanced Notes on the Eight Major Modules of Android” written by the senior architect of Ali, to help you organize the messy, scattered and fragmented knowledge systematically, so that you can systematically and efficiently Master the various knowledge points of Android development.
Compared with the fragmented content we usually read, the knowledge points of this note are more systematic, easier to understand and remember, and are arranged strictly according to the knowledge system.
Full set of video materials:
1. Interview Collection
2. Collection of source code analysis
3. Collection of open source frameworks
Welcome everyone to support with one click and three links. If you need the information in the article, you can directly scan the CSDN official certification WeChat card at the end of the article to get it for free↓↓↓
PS: There is also a ChatGPT robot in the group, which can answer your work or technical questions