1.Android studio 2020.3.1 编译Flutter报错:
? Unexpected lock protocol found in lock file. Expected 3, found 0.
2.解决Flutter编译一直显示 Running Gradle task 'assembleDebug'
1.修改 Flutter SDK 文件,位置:C:\flutter\packages\flutter_tools\gradle\flutter.gradle
// Code ......
buildscript {
repositories {
//google() // 注释掉
//mavenCentral() // 注释掉
/* 参考仓库地址:https://developer.aliyun.com/mvn/guide */
maven { url 'https://maven.aliyun.com/repository/google' } // 添加
maven { url 'https://maven.aliyun.com/repository/public' } // 添加
maven { url 'https://maven.aliyun.com/repository/public' } // 添加
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
}
}
//Code ......
apply plugin: FlutterPlugin
class FlutterPlugin implements Plugin<Project> {
//private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com";
private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn"; // 修改
// Code ......
// Configure the Maven repository.
String hostedRepository = System.env.FLUTTER_STORAGE_BASE_URL ?: DEFAULT_MAVEN_HOST
String repository = useLocalEngine()
? project.property('local-engine-repo')
: "$hostedRepository/download.flutter.io"
rootProject.allprojects {
repositories {
maven {
url repository
}
maven { url 'https://maven.aliyun.com/repository/google' } // 添加
maven { url 'https://maven.aliyun.com/repository/public' } // 添加
maven { url 'https://maven.aliyun.com/repository/public' } // 添加
}
}
2.修改项目文件:MyProject\android\flutter.gradle
buildscript {
ext.kotlin_version = '1.4.32'
repositories {
//google()
//mavenCentral()
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/public' }
}
3.关闭 Android studio 编辑器,删除目录及所有子文件和子目录:C:\Users\userName\.gradle
??注意是 .gradle 目录,前面有个点,类似于 Linux 的隐藏目录。启动编译时,编辑器会重新下载此目录下的文件。Gradle 是一个开源的 Android 官方构建自动化工具,官网如下:Gradle Build Toolhttps://gradle.org/
?4.重启一下编辑器,步骤:File -> Invalidate Caches/Restart -> Invalidate and Restart
|