flutter打包解决 Running Gradle task ‘assembleRelease‘...死循环问题

其实说到底就是国内访问google源太慢或者超时,所以两个方案

方案一:让自己能顺利访问google 懂得都懂
方案二:更换镜像地址,一共需要更换一下3个地方

1-更改 flutter/packages/flutter_tools/gradle/flutter.gradle文件

将google、mavencentral换成阿里云的镜像

buildscript {
    repositories {
// 修改前
//        google()
//        mavenCentral()

//修改后
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }

    }
    dependencies {
        /* When bumping, also update ndkVersion above. */
        classpath 'com.android.tools.build:gradle:4.1.0'
    }
}

2-更改flutter/packages/flutter_tools/gradle/resolve_dependencies.gradle文件

repositories {
//更改前
//    google()
//    mavenCentral()

//更改后
    maven { url 'https://maven.aliyun.com/repository/google' }
    maven { url 'https://maven.aliyun.com/repository/jcenter' }
    maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
    maven {
        url "$storageUrl/download.flutter.io"
    }
}

3-更改android/build.gradle文件

同上
buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
//        google()
//        mavenCentral()

        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }
    }

}

allprojects {
    repositories {
//        google()
//        mavenCentral()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public' }


    }
}

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