运行Flutter 真机运行安卓报错
当真机运行报以下错误时
* What went wrong: A problem occurred evaluating project ':app'. > Failed to apply plugin 'com.android.internal.application'. > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of the following options: - changing the IDE settings. - changing the JAVA_HOME environment variable. - changing `org.gradle.java.home` in `gradle.properties`. * 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
说明java的版本太低了
在Oracle 中下载java11的版本。下载结束后
放置在这个文件下面
配置.bash_profile及.zshrc文件路径
配置结束后用
source ~/.zshrc
source ~/.bash_profile
生效
java -version 查看是否已生效
进入flutter项目
进入到这个文件内/android/gradle.properties
添加java11路径
然后运行,会有很长一段等待时间,在下载。
这个时候需要打开梯子,通过梯子来下载对应程式,系统自己跑
下载完成后,就能在真机上运行了