flutter开发实战-Running Gradle task ‘assembleDebug‘ 的解决方法
使用Android studio经常出现Running Gradle task ‘assembleDebug‘问题,记录一下解决方法。
一、在Android目录下更改build.gradle
将repositories中的google(), mavenCentral()
repositories {google()mavenCentral()}
buildscript下的repositories与allprojects下的repositories均更改成aliyun
repositories {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' }}
更改后的结果如下
buildscript {ext.kotlin_version = '1.7.10'repositories {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 {classpath 'com.android.tools.build:gradle:7.2.0'classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"}
}allprojects {repositories {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' }}
}rootProject.buildDir = '../build'
subprojects {project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {project.evaluationDependsOn(':app')
}task clean(type: Delete) {delete rootProject.buildDir
}
二、更改 “$flutterRoot/packages/flutter_tools/gradle/flutter.gradle”
将buildscript中repositories下的google()mavenCentral()更换成阿里云
buildscript {repositories {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:7.3.0'}
}
三、更改 “$flutterRoot/packages/flutter_tools/gradle/resolve_dependencies.gradle”
将repositories中的google()mavenCentral()更换成阿里云
repositories {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"}
}
学习记录,每天不停进步。