Welcome to like, reprint please indicate the source

Create a Flutter App

If you start up the Flutter SDK as described above and configure the Flutter Plugins properly in Android Studio, you will see the following screen:

Do not select Include Kotlin supprot for Android code and Include Swift support for iOS code

Running apps on Android devices

For simplicity, you can connect an Android phone to the USB port of your computer. Before connecting, you need to set the ANDROID phone USB debugging available in the Developer options. General setting method is: on Android device 4.2 or higher version find [Settings] -> click [about device] -> find [system version number] and continuously tap 7 times; -> Go back to [Settings] and click [Developer Options]; -> Enable USB debug mode. When connecting the device for the first time, the Android device will generally have the pop-up authorization whether to allow USB debugging, as shown in the following figure. Select always allow:

target selector

Run

Thermal overload

Flutter provides a thermal reloading feature that allows code changes to take effect in real time without requiring an application restart.

  1. To keep the App on, open the lib\main.dart file:

Apple devices run apps

The iPhone connects to the computer via USB and chooses to trust the computer. Select a connected Apple device in Android Studio and run the Flutter App. When the Flutter App runs for the first time, it will say “No valid code signing certificates were found”. Because apple projects require an iOS Provisioning Profile:

Note: Always have a Flutter App that has been certified and installed on Your Device. This will avoid the need for apple devices to set up personal development certificate trust repeatedly.

The project structure

The project structure after compilation and running is shown as follows:

  • .dart_tool/
  • .packages
  • pubspec.lock
  • ios/Flutter/App.framework
  • ios/Flutter/Flutter.framework

If you are using JetBrains’ IDE, the.idea/ directory does not need to be submitted.

For a complete list of documents that do not need to be submitted, see the official.gitigore note

Android emulator

For Windows, if you don’t have a real Android, you can use the Emulator provided by Android Studio or install third-party Emulator software, such as Genymotion. You can refer to Zhang’s introduction to download and use the Emulator. On macOS, if you don’t have a real machine, it’s easier to use Xcode Simulator. In addition to the basic system requirements of Android Studio, the Android emulator also needs to meet the following requirements:

  • SDK Tools 26.1.1 or later
  • 64-bit processor
  • Windows: SUPPORT UG (unrestricted visitor) CPU
  • HAXM 6.2.1 or later (HAXM 7.2.0 or later is recommended)


  • Intel processors on Windows: The Intel processor must support the Intel VT-X, Intel EM64T (Intel 64), and Execute Disable (XD) Bit functions
  • AMD processors on Windows: Android Studio 3.2 or later and Windows 10 or later released in April 2018 with Support for Windows Hypervisor Platform (WHPX) functionality are required

Creating and managing android emulator virtual devices is relatively easy, which is described here. If in doubt, refer to the official instructions.

Q&A

When a problem occurs, run the Flutter Doctor first and fix the error as prompted. Even if the previous flutter Doctor tests have passed, errors may occur again as the application environment changes.

  • The Flutter SDK path is not given as shown below:

    Check that the PATH setting of the flutter environment variable points correctly to the flutter installation directory. Either manually select the Flutter SDK path TAB or enter the global Settings in the AS AS shown below:

  • The flutter SDK installation is incomplete, as follows:

    Execute the Flutter Doctor for diagnosis, or re-update the download using flutter Upgrade.

  • Could not resolve io.flutter:flutter_embedding_debug…

    There may be a problem with the stability of Flutter 1.12. You can consider reverting to a previous stable flutter version such as Flutter 1.9.

  • User rejected permission

    For the first time, a human on an Android phone agrees to use a trusted computer link.

  • Gradle Synce Issues: Read timed out

    Or the interface similar to the following is displayed:

    Because the Gradle source is in a foreign country, it is slow to synchronously download dependent projects, so we can consider changing it to ali’s domestic mirror service address. Update the build.gradle file in android folder (Note: Not an Android /app build.gradle file). Add the following code snippet:

repositories {
        google()
        jcenter()
        
    }
    
allprojects {
    repositories {
        google()
        jcenter()
        
    }
Copy the code

Update as follows:

repositories {
        maven {
            url 'https://maven.aliyun.com/repository/google'
        }
        maven {
            url 'https://maven.aliyun.com/repository/public'
        }
        maven {
            url 'https://maven.aliyun.com/repository/jcenter'
        }
    }
    
    
allprojects {
    repositories {
        maven {
            url 'https://maven.aliyun.com/repository/google'
        }
        maven {
            url 'https://maven.aliyun.com/repository/public'
        }
        maven {
            url 'https://maven.aliyun.com/repository/jcenter'}}Copy the code
  • Minimun supported Gradle version is ….

This is caused by a discrepancy between the Gradle version required by Android Studio and the Gradle version automatically generated by the Flutter project. Select Fix Gradle Wrapper and re-import project as prompted.

  • Please configure Android SDK

    Open File->Project Structure check, you can see:

    Gradle is not configured correctly. Close the current project, File->Open, Open the Android directory under the current project, you can see the following:

    Gradle Sync then executes again. If the synchronization succeeds, close the current Flutter project and reopen the previous Flutter project.

    You can also open it in the following ways:

  • unable to find valid certifcation path to required target

    Online solutions can be searched for many, but may not solve the problem. You can refer toXiao Wu’s shoe solution

  • Waiting for another flutter command to release the startup lock…

Due to some abnormal operation, before a flutter command did not complete, can to flutter installation directory delete flutter/bin/cache/lockfile this file, lockfile file size of 0 bytes, just for marking.

The experiment of a

Complete the project functions in this section, delete unnecessary files, and compress the project into a zip file. Ensure that the zip file cannot exceed 500Kb.

Extension: About Gradle

Gradle is an open source build automation tool focused on flexibility and performance. Gradle build scripts are written using Groovy or Kotlin DSL(Domain-specific Language). Gradle supports many major ides, including Android Studio, Eclipse, IntelliJ IDEA, Visual Studio 2019 and XCode. If you only want to run existing Gradle builds, you can identify gradlew(used for macOS) and/or gradlew. Bat (used for Windows) files in the build root directory if there is a Gradle Wrapper in the build, without installing Gradle. By default, new Flutter projects will have this file, as shown below. The project is built using Gradle 4.10.2. You can also manually modify the file version information.

The Android Studio build system is based on Gradle, installed and the Android Gradle plugin adds several features specifically for building Android applications. While Android plug-ins usually update at the same pace as Android Studio, plug-ins (and the rest of the Gradle system) can run independently of Android Studio and be updated separately. The Android Gradle plugin can be specified in the File > Project Structure > Project menu of Android Studio or in the top-level build. Gradle File. This plug-in version works with all modules built in the corresponding Android Studio project. The following image shows the Gradle plugin version 3.2.1. You can also manually modify the file version information:


  • Choosing a stable version to update does not mean that the newer version is better.
  • Try to keep the version information used by default for new projects;
  • Gradle is not compatible with the syntax and usage of the previous version. You need to follow the instructions given by Android Studio to modify the app/build.gradle.
  • There is a correspondence between Android Gradle plugin versions and Gradle versions. Sometimes you need to modify both versions at the same time.
  • Android Gradle plugin 3.5.0 requires SDK build-Tools 28.0.3 or above.
  • Android Studio also has requirements for the smallest version of Android Gradle plug-in. You can follow the instructions of Android Studio to modify the synchronization.

Previous Article Flutter Installation (Windows) Next article Hello Widget