简体   繁体   English

无法使用 IntelliJ 在 android 设备上运行 flutter 项目

[英]Can't run flutter project on android device with IntelliJ

My operating system is Pop._OS 20.10, I am simply trying to run a flutter project, which I created on IntelliJ.我的操作系统是 Pop._OS 20.10,我只是想运行我在 IntelliJ 上创建的 flutter 项目。 on my android device using IntelliJ IDEA, The build is being completed without any errors but when running the app: it says that my JAVA_HOME variable is set to an invalid directory:在我使用 IntelliJ IDEA 的 android 设备上,构建正在完成,没有任何错误,但是在运行应用程序时:它说我的 JAVA_HOME 变量设置为无效目录:

Launching lib/main.dart on Mi A2 in debug mode...
Running Gradle task 'assembleDebug'...

ERROR: JAVA_HOME is set to an invalid directory: /app/extra/idea-IU/jre64

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Exception: Gradle task assembleDebug failed with exit code 1

SDKs installed on my platform settings are openjdk-15.0.2, corretto-1.8 and Android API 30 Platform.在我的平台设置上安装的 SDK 是 openjdk-15.0.2、corretto-1.8 和 Android API 30 平台。 I didn't manually altered any environment variables before getting this error.在收到此错误之前,我没有手动更改任何环境变量。 After this, I tried to add JAVA_HOME variable to ~/.bashrc and /etc/environment files to point my JDK installation folder like this:在此之后,我尝试将 JAVA_HOME 变量添加到~/.bashrc/etc/environment文件以指向我的 JDK 安装文件夹,如下所示:

JAVA_HOME="/usr/lib/jvm/default-java"

and also tried with my current java installation:并且还尝试了我当前的 java 安装:

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

but no luck.但没有运气。 I did a lot of research and really don't know what to do at this point.我做了很多研究,现在真的不知道该怎么办。

There are two possibilities有两种可能

1 - Your flutter sdk is may be some old version. 1 - 您的 flutter sdk 可能是一些旧版本。 Run flutter upgrade to update your flutter sdk.运行flutter upgrade以更新您的 flutter sdk。

2 - You might not have installed JDK or the JDK Path is not set in Environment Variables. 2 - 您可能没有安装 JDK 或未在环境变量中设置 JDK 路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM