flutter 打包apk报错

按照官方文档签名等一些工作配置好了之后。开始使用flutter命令打包apk。在终端执行flutter build apk后等了一段时间后出现如下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:releaseCompileClasspath'.
   > Could not resolve io.flutter:x86_64_release:1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd.
     Required by:
         project :app
      > Could not resolve io.flutter:x86_64_release:1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_release/1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd/x86_64_release-1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_release/1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd/x86_64_release-1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/172.217.24.16] failed: Connection timed out: connect
      > Could not resolve io.flutter:x86_64_release:1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd.
         > Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_release/1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd/x86_64_release-1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd.pom'.
            > Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/x86_64_release/1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd/x86_64_release-1.0.0-2d42c74a348d98d2fd372a91953c104e58f185cd.pom'.
               > Connect to storage.googleapis.com:443 [storage.googleapis.com/172.217.24.16] failed: Read timed out

* 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 6m 39s

可能由于网络因数,第一次打包不能支持多个平台,那么支持arm平台就可以了。

所以执行命令如下

 flutter build apk --target-platform android-arm

运行之后就可以了,并且下面执行的命令打出的包的体积也要小一些。

 

如果flutter打包出来的apk安装到android手机上可以运行,但是无法访问网络,那么在flutter项目中的android/app/src/main/AndroidMast.xml文件下把网络权限添加上。

不知道为什么在debug模式下不添加是可以访问的。打包之后不添加是不可以的。所以容易疏忽。

 

如果文章有问题,或者建议,欢迎下方评论

 

 

 

 

 

你可能感兴趣的:(flutter)