flutter开发实战-Running Gradle task ‘assembleDebug‘ 的解决方法

flutter开发实战-Running Gradle task ‘assembleDebug‘ 的解决方法

使用Android studio经常出现Running Gradle task ‘assembleDebug‘问题,记录一下解决方法。
flutter开发实战-Running Gradle task ‘assembleDebug‘ 的解决方法_第1张图片

一、在Android目录下更改build.gradle

flutter开发实战-Running Gradle task ‘assembleDebug‘ 的解决方法_第2张图片

将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
}

flutter开发实战-Running Gradle task ‘assembleDebug‘ 的解决方法_第3张图片

二、更改 “$flutterRoot/packages/flutter_tools/gradle/flutter.gradle”

flutter开发实战-Running Gradle task ‘assembleDebug‘ 的解决方法_第4张图片

将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”

flutter开发实战-Running Gradle task ‘assembleDebug‘ 的解决方法_第5张图片

将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"
    }
}

学习记录,每天不停进步。

你可能感兴趣的:(flutter开发实战,flutter,移动开发,flutter,Running,Gradle,assembleDebug,Android,android,studio)