flutter的环境安装配置问题及解决方法

来自:网络
时间:2020-10-14
阅读:

Flutter简介

Flutter是Google推出的基于Dart语言开发的跨平台开源UI框架,旨在统一纷纷扰扰的跨平台开发框架,在UI层面上多端共用一套Dart代码来实现多平台适配开发。目前应用比较广泛的还是移动端iOS和安卓,虽然传言Fuchsia会是亲儿子项目,那也不是当下考虑的。

下面重点给大家介绍下flutter的环境安装配置问题及解决方法。

(1)安装android SDK时,会出现Android license 的问题,将JAVA JDK降级到SE8就可以了,很多版本没对应上,JAVA8是比较稳定的,包括后面的gradle也需要基于JAVA8

问题描述:[!] Android toolchain - develop for Android devices (Android SDK 27.0.3) ✗ Android license status unknown.

解决:安装JAVA8后,运行 flutter doctor --android-licenses

(2) 卡在Running ‘gradle assembleDebug运行阶段,引用国内阿里云的镜像解决。

问题描述:Running Gradle task 'assembleDebug'...

解决:

  修改项目中`android/build.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'
  }
}
 
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' }
  }
}
 
rootProject.buildDir = '../build'
subprojects {
  project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
  project.evaluationDependsOn(':app')
}
 
task clean(type: Delete) {
  delete rootProject.buildDir
}

 修改Flutter的配置文件, 该文件在`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'
  }
}
返回顶部
顶部