Flutter development actual combat-Running Gradle task 'assembleDebug' solution
The Running Gradle task 'assembleDebug' problem often occurs when using Android studio, and record the solution.
1. Change build.gradle in the Android directory
Will google(), mavenCentral() in repositories
repositories {
google()
mavenCentral()
}
Both repositories under buildscript and repositories under allprojects are changed to 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' }
}
The changed result is as follows
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”
Replace google() mavenCentral() under repositories in buildscript with Alibaba Cloud
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”
Replace google() mavenCentral() in repositories with Alibaba Cloud
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"
}
}
Learning records, keep improving every day.