Flutter踩坑记录
1. 运行卡在各种build,超时
1.1. 修改Flutter的配置
在文件 \flutter\packages\flutter_tools\gradle\flutter.gradle
中进行如下改动:
repositories {
// 原来默认是下面两行
// google()
// jcenter()
// 替换成下面的三行
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
1.2. 修改项目的配置
在文件 \android\build.gradle
中进行如下改动(与上一步骤相同,但是本文件中有两处需要修改):
repositories {
// 原来默认是下面两行
// google()
// jcenter()
// 替换成下面的三行
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
1.3. 修改项目的配置
在文件 \android\gradle\wrapper\gradle-wrapper.properties
中进行如下改动:
# 原来是下面这行
# distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
# 改成下面这行,下面的文件是你下载的gradle版本
distributionUrl=gradle-6.6-all.zip
同时将 gradle-6.6-all.zip
文件放入目录 \android\gradle\wrapper
中
2. 获取 SHA-1
https://stackoverflow.com/questions/55496090/how-to-get-sha1-of-android-app-in-vs-code
It’s very simple follow below steps.
- Step 1. Go to your project directory in VS code.
- Step 2. Open terminal.
- Step 3. Run
cd android
for the below path :
Ex.: PS D:\Workspace\FlutterWorkSpace\FlutterApp\flutter_demo_app> cd android - Step 4. Run
.\gradlew signingReport
for the below path :
PS D:\Workspace\FlutterWorkSpace\FlutterApp\flutter_demo_app\android> .\gradlew signingReport