admin管理员组

文章数量:1548483

这里写自定义目录标题

  • 一. 新建的flutter项目安卓模拟器不能使用
  • 二当上面操作完成以后,新建的flutter项目可以使用安卓模拟器,但是老项目不好使的解决方法

在flutter项目中,ios模拟器好使,安卓模拟器不好使.
分为2种情况:

一. 新建的flutter项目安卓模拟器不能使用

但是在android studo中新建安卓项目,却可以用安卓模拟器运行启动.
解决方法:
1.首先启动vpn,让项目可以提示错误.
2.然后再android studo中运行,如果报错,可能会显示一个版本号,例如:30.0.3
那么就设置 android studo的Android SDK,快捷键 command+, 设置Android SDK Location:看看路径是不是正确,进入到硬盘里看看有没有对应的版本号
然后到下面SDK Tools分页里面找到,报错的保本好,打上勾,点击右下角ok,进行安装

3.打开Device Manager,把之前的安卓模拟器直接删掉,重新安装.

安装新的设备,选择Create device

选择api的时候选择,已经有的api没有就点击下载,然后点击next->Finish

重新安装以后再启动flutter项目可以解决之前版本报错问题

二当上面操作完成以后,新建的flutter项目可以使用安卓模拟器,但是老项目不好使的解决方法

有时候启动老的flutter项目提示错误如下:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
   > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven3(http://maven.aliyun/nexus/content/groups/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle/7.4/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 

* 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

BUILD FAILED in 641ms
Running Gradle task 'assembleDebug'...                           1,145ms
Exception: Gradle task assembleDebug failed with exit code 1

这个原因是build.gradle文件配置有问题,解决方法:
把上面第一种方法,新建的flutter项目可以启动安卓模拟器的项目打开,找到项目目录下/android/build.gradle 这个文件,把它复制,覆盖不好使的项目,再运行就可以让老的项目里,不能运行安卓模拟器的项目可以运行

本文标签: 好使模拟器项目Flutter