Flutter问题解决之 Waiting for another flutter command to release the startup lock.

前段时间系统重装了一次之后,执行Flutter的Packages get一直卡在这里,再执行一次报这个问题Waiting for another flutter command to release the startup lock.查看了一下资料,找到了以下方法:

 

1:关闭 as

2:CTRL+ALT+DEL 关闭所有 dart进程和android进程,注意adb这个别忘了关

3:打开 flutter 安装目录  如:...\flutter\bin\cache

    删除里面的 lockfile

4:打开 as 先点击下面的 Invalidate 再打开此窗口 点击 Just Restart。

执行以上操作,然后有反应了,报了以下问题:

OS Error: 信号灯超时时间已到

, errno = 121, address = pub.dartlang.org, port = 53249

 虽然遇到了新问题,但也算一种进展吗?不怕它有反应,就怕它没反应啊!继续查询相关问题~

Google搜索一下,原来flutter 已经有对策了。

Using Flutter in China 。

大概意思就是 把默认的 package 获取地址改为访问没有问题的镜像站就可以了。

具体操作

  • Linux 或 Mac

export PUB_HOSTED_URL=https://pub.flutter-io.cn

export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn

  • Windows

新增两个环境变量即可

PUB_HOSTED_URL ===== https://pub.flutter-io.cn

FLUTTER_STORAGE_BASE_URL ===== https://storage.flutter-io.cn

执行一下 flutter doctor命令

下载在 package get 应该就没有问题了。

flutter混合开发运行报错:VM snapshot must be valid. /Check failed: vm. Must be able to initialize the VM.

在现有android项目中集成flutter_boost时,运行host app发生崩溃:

VM snapshot must be valid. 
Check failed: vm. Must be able to initialize the VM.

查找资料得知,需要将flutter_sdk目录下packages/flutter_tools/gradle/flutter.gradle:
这句话
variant.outputs[0].processResources.dependsOn(copyFlutterAssetsTask)
改为
variant.outputs[0].processResources.dependsOn(flutterTask)

另外需要在fluttermodule的build文件Flutter/build.gradle的android{}节点添加:

project.android.libraryVariants.all { variant ->
    def targetAssets = "${project.buildDir}/intermediates/flutter/${variant.name}"
    def customSourceSet = variant.getSourceSets()[0]
    if (customSourceSet instanceof com.android.build.gradle.internal.api.DefaultAndroidSourceSet) {
        customSourceSet = (com.android.build.gradle.internal.api.DefaultAndroidSourceSet)customSourceSet
        customSourceSet.getAssets().srcDirs(targetAssets)
    }
}

对比项目,fluttermodule/.android/Flutter/Build/intermediates/flutter文件夹下,如果缺少debug/flutter_assets会导致主项目Flutter下也缺少这个文件夹,导致项目崩溃。

对比apk发现,assets文件夹下缺少flutter_shared或者flutter_assets会导致以上崩溃。

Flutter 打包问题 Could not resolve io.flutter:arm64_v8a_release解决


问题日志

Running Gradle task 'assembleRelease'...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:processReleaseResources'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
   > Could not resolve io.flutter:arm64_v8a_release:1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.
     Required by:
         project :app
      > Could not resolve io.flutter:arm64_v8a_release:1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.16] failed: Connection timed out: connect
      > Could not resolve io.flutter:arm64_v8a_release:1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.80] failed: Connection timed out: connect
      > Could not resolve io.flutter:arm64_v8a_release:1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/arm64_v8a_release/1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90/arm64_v8a_release-1.0.0-b851c718295a896918dc93cb1ff14f2f895a1b90.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/34.64.4.80] failed: Connection timed out: connect

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org
BUILD FAILED in 8m 15s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                     496.8s (!)
Gradle task assembleRelease failed with exit code 1


解决办法

1.你自己的磁盘:\flutter\packages\flutter_tools\gradle\flutter.gradle

buildscript {
    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'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
    }
}
class FlutterPlugin implements Plugin<Project> {
	//原下载路径
 	//private static final String MAVEN_REPO      = "https://storage.googleapis.com/download.flutter.io";
 	//修改后的下载路径
    private static final String MAVEN_REPO      = "https://storage.flutter-io.cn/download.flutter.io"

project.rootProject.allprojects {
            repositories {
                maven {
                    url repository
                }
                ///增加这段代码
				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'
            }
}

2.项目位置:项目名/android/build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
       /*   google()
          jcenter()*/
        maven{ url 'https://maven.aliyun.com/repository/google' }
        maven{ url 'https://maven.aliyun.com/repository/jcenter' }
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
      /*   google()
         jcenter()*/
        maven{ url 'https://maven.aliyun.com/repository/google' }
        maven{ url 'https://maven.aliyun.com/repository/jcenter' }
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


解决成功日志

	G:\workspaces\intelligent-logistics-app>flutter  build apk
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more on: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more on:  https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...
Removed unused resources: Binary resource data reduced from 894KB to 884KB: Removed 1%
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                     216.2s (!)
√ Built build\app\outputs\apk\release\app-release.apk (27.0MB).

解决Error: Unable to ‘pub upgrade‘ flutter tool


运行 flutter doctor时终端报错信息如下:

Updating flutter tool...
The system cannot find the path specified.
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds...

删除 flutter'\bin 目录下的 cache 文件夹,重新运行flutter doctor
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值