flutter environment to build their encounter pits

Overall it needs four things, evens out the configuration click on OK;

  • SDK Flutter [ https://flutter.io/docs/get-started/install/windows ] (recommended to download the official website, can be downloaded directly)

  • Download Dart plug

  • Download Flutter plugin

    • Configuration environment variable
  • Ready ide (Androidstudio or IntelliJ IDEA) configuration flutter of the SDK

Problems encountered:

  • You can not download the plug-in problem

    File->Settings->Apparence & Behavior->System Settings->Updates->use secure connnection
    
    勾去掉
    
  • File failed to load, for Ali mirror

    * Error running Gradle:
    ProcessException: Process "E:\flutter\demo\flutter_app\android\gradlew.bat" exited abnormally:
    Starting a Gradle Daemon (subsequent builds will be faster)
    
    > Configure project :app
    
    Project evaluation failed including an error in afterEvaluate {}. Run with --stacktrace for details of the afterEvaluate {} error.
    
    FAILURE: Build failed with an exception.
    
    * Where:
    Build file 'E:\flutter\demo\flutter_app\android\app\build.gradle' line: 26
    
    * What went wrong:
    A problem occurred evaluating project ':app'.
    > Could not resolve all artifacts for configuration 'classpath'.
       > Could not download kotlin-reflect.jar (org.jetbrains.kotlin:kotlin-reflect:1.2.0)
          > Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.2.0/kotlin-reflect-1.2.0.jar'.
             > Could not HEAD 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-reflect/1.2.0/kotlin-reflect-1.2.0.jar'.
                > Connect to d29vzk4ow07wi7.cloudfront.net:443 [d29vzk4ow07wi7.cloudfront.net/13.32.253.234, d29vzk4ow07wi7.cloudfront.net/13.32.253.66,
                d29vzk4ow07wi7.cloudfront.net/13.32.253.201, d29vzk4ow07wi7.cloudfront.net/13.32.253.237] failed: Read timed out
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 2m 13s
      Command: E:\flutter\demo\flutter_app\android\gradlew.bat app:properties
    
    
    Please review your Gradle project setup in the android/ folder.
    
    

        flutter_app/android/build/gradle中修改文件
        
        repositories {
            //google()
            //jcenter()
            maven{ url 'https://maven.aliyun.com/repository/google' }
            maven{ url 'https://maven.aliyun.com/repository/jcenter' }
            maven{url 'http://maven.aliyun.com/nexus/content/groups/public'}
        }
    
        allprojects {
            repositories {
                //google()
                //jcenter()
                maven{ url 'https://maven.aliyun.com/repository/google' }
                maven{ url 'https://maven.aliyun.com/repository/jcenter' }
                maven{url 'http://maven.aliyun.com/nexus/content/groups/public'}
            }
        }
    

    在 flutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle这个文件修改一下(或者使用翻墙软件也行),我就使用一下阿里的镜像服务器把
    
    buildscript {
        repositories {
            //google()
            //jcenter()
    	maven{ url 'https://maven.aliyun.com/repository/google' }
            maven{ url 'https://maven.aliyun.com/repository/jcenter' }
            maven{url 'http://maven.aliyun.com/nexus/content/groups/public'}
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
        }
    }
    

  • Lack-bundle ndk ( https://developer.android.google.cn/ndk/downloads/ )

        * Error running Gradle:
        ProcessException: Process "E:\flutter\demo\flutter_app\android\gradlew.bat" exited abnormally:
        
        > Configure project :app
        Checking the license for package Android SDK Platform 27 in C:\Users\kingsoft\AppData\Local\Android\sdk\licenses
        Warning: License for package Android SDK Platform 27 not accepted.
        
        
        FAILURE: Build failed with an exception.
        
        * Where:
        Build file 'E:\flutter\demo\flutter_app\android\build.gradle' line: 26
        
        * What went wrong:
        A problem occurred evaluating root project 'android'.
        > A problem occurred configuring project ':app'.
           > Failed to install the following Android SDK packages as some licences have not been accepted.
                platforms;android-27 Android SDK Platform 27
             To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
             Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
        
             Using Android SDK: C:\Users\kingsoft\AppData\Local\Android\sdk
        
        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
        
        E:\flutter\demo\flutter_app>flutter run
        Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with
        "--enable-software-rendering".
        Launching lib/main.dart on Android SDK built for x86 in debug mode...
        Initializing gradle...                                       0.9s
        Resolving dependencies...
        * Error running Gradle:
        ProcessException: Process "E:\flutter\demo\flutter_app\android\gradlew.bat" exited abnormally:
        
        > Configure project :app
        Checking the license for package Android SDK Platform 27 in C:\Users\kingsoft\AppData\Local\Android\sdk\licenses
        Warning: License for package Android SDK Platform 27 not accepted.
        
        
        FAILURE: Build failed with an exception.
        
        * Where:
        Build file 'E:\flutter\demo\flutter_app\android\build.gradle' line: 32
        
        * What went wrong:
        A problem occurred evaluating root project 'android'.
        > A problem occurred configuring project ':app'.
           > Failed to install the following Android SDK packages as some licences have not been accepted.
                platforms;android-27 Android SDK Platform 27
             To build this project, accept the SDK license agreements and install the missing components using the Android Studio SDK Manager.
             Alternatively, to transfer the license agreements from one workstation to another, see http://d.android.com/r/studio-ui/export-licenses.html
        
             Using Android SDK: C:\Users\kingsoft\AppData\Local\Android\sdk
        
        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
        
        * Get more help at https://help.gradle.org
        
        BUILD FAILED in 9s
          Command: E:\flutter\demo\flutter_app\android\gradlew.bat app:properties
        
        
        Please review your Gradle project setup in the android/ folder.
    
  • Build file ‘E:\flutter\project\flutter_app\android\build.gradle’ line: 32

创建一个lib【common】,app:依赖【common】出现该原因

subprojects {
//    project.evaluationDependsOn(':app')
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if (details.requested.group == 'com.android.support'
                    && !details.requested.name.contains('multidex') ) {
                details.useVersion "27.1.1"
            }
        }
    }
}!

Guess you like

Origin blog.csdn.net/luchuanqi67/article/details/91283884