Deepin v20 Flutter from zero configuration (Ubuntu theory applies)

Deepin v20 Flutter from zero configuration (Ubuntu theory applies)

The most detailed Flutter configuration instructions on the entire network, Ubuntu theory applies

  1. Resource preparation

    • Android Studio

      Download Android Studio and unzip

      Configure init.gradleand configure domestic sources to avoid slow running of Android Studio

      Create a .gradle directory under the HOME directory

      mkdir .gradle
      

      Click to downloadinit.gradle file

      Placed in the .gradle directory

      Double-click studio.sh under /android-studio/bin (just select run in the pop-up window)

      Press the default setting and click all the way. When you encounter a proxy window with a red exclamation mark, click cancel, and then wait for the download of all necessary components to complete.

      • Configure Android Studio environment to the system

        sudo deepin-editor ~/.bashrc
        

        注:Ubuntu 应该是以下命令,下文提到的类似操作均是如此,不再重复说明,Deepin用户 请忽略这一说明。

        sudo nano /etc/profile
        

        Add :( note at the end of the following file .bashrc usernamechanged their deepin用户名)

        # For Android Studio
        export ANDROID_HOME=/home/username/Android/Sdk
        export PATH=$PATH:$ANDROID_HOME/tools
        export PATH=$PATH:$ANDROID_HOME/tools/bin
        export PATH=$PATH:$ANDROID_HOME/platform-tools
        export PATH=$PATH:$ANDROID_HOME/emulator
        

        Close the editor and refresh ~/.bashrc

        source ~/.bashrc
        

        注:Ubuntu 应该是以下命令,下文提到的类似操作均是如此,不再重复说明。

        source /etc/profile
        
      • test

        adb
        

        If output

        Android Debug Bridge version 1.0.41
        Version 30.0.4-6686687
        Installed as /home/username/Android/Sdk/platform-tools/adb
        ...省略大量说明
        

        That is, the configuration is successful

    • Visual Studio Code

      Download and install vs code

      Install the following plugins in the extension store

      • chinese
      • flutter
    • jdk8

      Download jdk8 (requires registration to log in to Oracle) and unzip

      Create a jvm folder in the /usr/lib/ directory

      sudo mkdir /usr/lib/jvm
      

      Enter the directory where the downloaded jdk is located, and move the decompressed directory jdk1.8.0_261 to /usr/lib/jvm/

      sudo mv jdk1.8.0_261 /usr/lib/jvm/
      

      Configure Java to the system environment

      sudo deepin-editor ~/.bashrc
      

      Add at the end of the .bashrc file:

      # For JAVA
      export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_261
      export JRE_HOME=${JAVA_HOME}/jre
      export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
      export PATH=${JAVA_HOME}/bin:$PATH
      

      Close the editor and refresh ~/.bashrc

      source ~/.bashrc
      

      test

      java -version
      

      If output

      java version "1.8.0_261"
      Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)
      

      That is, the configuration is successful

    • Flutter

      Download git

      sudo apt install git -y
      

      Download Flutter (depending on personal network speed), pay attention to the location of clone, I run this command in the home directory, this will create a flutter directory in the home directory, just together with Android

      git clone https://github.com/flutter/flutter.git
      

      Configure Flutter to the system environment

      sudo deepin-editor ~/.bashrc
      

      Add :( note at the end of the following file .bashrc usernamechanged their deepin用户名)

      # For Flutter
      export PATH=/home/username/flutter/bin:$PATH
      export PUB_HOSTED_URL=https://mirrors.tuna.tsinghua.edu.cn/dart-pub
      export FLUTTER_STORAGE_BASE_URL=https://mirrors.tuna.tsinghua.edu.cn/flutter
      

      Close the editor and refresh ~/.bashrc

      source ~/.bashrc
      

      Check the Flutter environment, and download the Dart SDK for the first run (depending on personal network speed)

      flutter doctor
      

      Output (if you want to write a project in AS, just install the Flutter plug-in, here is VS Code as an example, AS will not repeat it)

      [] Flutter (Channel master, 1.22.0-10.0.pre.161, on Linux, locale zh_CN.UTF-8)
       
      [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
          ✗ Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses
      [!] Android Studio (version 4.0)
          ✗ Flutter plugin not installed; this adds Flutter specific functionality.
          ✗ Dart plugin not installed; this adds Dart specific functionality.
      [] VS Code (version 1.49.0)
      [!] Connected device
          ! No devices available
      

      Verify the Android certificate (note that if it is not jdk8 here, an error will be reported)

      flutter doctor --android-licenses
      

      Just go all the way


      Modify the default Flutter source

      Enter the following directory flutter/packages/flutter_tools/gradle/flutter.gradle file:

      amend as below:

      //...
      buildscript {
           repositories {
               //google()
               //jcenter()
               maven { url 'https://maven.aliyun.com/repository/google' }
               maven { url 'https://maven.aliyun.com/repository/jcenter' }
               maven { url 'https://maven.aliyun.com/repository/public' }
           }
           dependencies {
               classpath 'com.android.tools.build:gradle:3.5.0'
           }
       }
      //...
      

      Save and exit

  2. Experience Flutter

    • Create a new application

      1. Start VS Code

      2. Call View>Command Palette… (or Ctrl + Shift + P ,F1)

      3. Type in'flutter', then select the'Flutter: New Project' action

      4. Enter the name of the Project (eg myapp), then press Enter

      5. Specify where to place the item and press the blue OK button

      6. Wait for the project creation to continue, and display the main.dart file

      …Experience Flutter content from the Flutter Chinese website to view by yourself

At this point, the Flutter environment has been fully configured, and enjoy it!

Guess you like

Origin blog.csdn.net/qq_41238308/article/details/108591833