androidstudio搭建flutter环境,遇到的问题

flutter支持的开发工具有ieda和androidstudio,当然还有其它的,我只搭建了这两个环境。

Windows环境下搭建

1.Androidstudio的相关环境和搭建,还有jdk的环境变量,Android的sdk配置,这里就不说了,请自行解决,并能编译一个helloWorld的app。

2.下载flutter的SDK   https://flutter.io/sdk-archive,下载稳定版

3.配置环境变量,在系统环境变量的Path里面配置

   例如:D:\flutter\flutter_windows_1.17.5-stable\flutter\bin

   androidstudio搭建flutter环境,遇到的问题_第1张图片

 

  androidstudio搭建flutter环境,遇到的问题_第2张图片

4.在androidstudio里面下载flutter

  androidstudio --settings--Plugins

androidstudio搭建flutter环境,遇到的问题_第3张图片

基本的环境变量已经配置好了,

新建flutter项目

androidstudio搭建flutter环境,遇到的问题_第4张图片

上面就是配置到新建一个flutter项目的过程,

我是这样,但是没有运行起来,一直卡在gradle的编译位置,

最后修改如下:

你自己的磁盘:\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.5.0'
    }
}
project.rootProject.allprojects {
            repositories {
                maven {
                    url repository
                }
                ///增加这段代码
				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'
            }
}

然后重新编译,起码能编译了,不是一直卡着不动

编译出现如下问题

Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:processReleaseResources'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
   > Could not resolve io.flutter:arm64_v8a_release:1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.
     Required by:
         project :app
      > Could not resolve io.flutter:arm64_v8a_release:1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.16] failed: Connection timed out: connect
      > Could not resolve io.flutter:arm64_v8a_release:1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.80] failed: Connection timed out: connect
      > Could not resolve io.flutter:arm64_v8a_release:1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.80] failed: Connection timed out: connect


方法一:再次修改刚才那个文件

class FlutterPlugin implements Plugin {
	//原下载路径
 	//private static final String MAVEN_REPO      = "https://storage.googleapis.com/download.flutter.io";
 	//修改后的下载路径
    private static final String MAVEN_REPO      = "https://storage.flutter-io.cn/download.flutter.io"
}

这样再次编译,结果就成功了

方法二:

在自己Android项目中build.gradle下

换成

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://storage.googleapis.com/download.flutter.io" }
    }
}

也可以编译完成

我的build.gradle,可以参考

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
//        google()
//        jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
//        google()
//        jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        maven { url "https://storage.googleapis.com/download.flutter.io" }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

androidstudio搭建flutter环境,遇到的问题_第5张图片

 

 

你可能感兴趣的:(android,flutter,android,android,studio)