离子Cordova运行Android和Java版本

发布于 2025-02-12 03:28:42 字数 1181 浏览 2 评论 0原文

因此,我基本上是在尝试在Android设备上运行我的离子应用程序,并且命令“ Ionic Cordova Run Android - 设备”到了告诉我出现错误的原因是:

Requirements check failed for JDK 1.8.x! Detected version: 16.0.0
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.

因此,在验证我拥有的Java版本之后,成功将版本更改为1.8.x,因此当我运行Java -version时,它会返回:

java version "1.8.0_251"

但是,运行“ Ionic Cordova运行Android - 设备”,它返回相同的原始错误:

 Requirements check failed for JDK 1.8.x! Detected version: 16.0.0
    Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.

经过更多的研究,我意识到,我意识到它的Javac版本告诉我另一个版本,我相信它必须相同。因此,当我运行“ Javac -version”时,我会得到:

javac 16

所以...我不知道如何将Javac版本更改为与Java相同,我唯一认为它可能是有路径的东西,但是主题有些混乱,因为我不确定下一步该怎么做?

我在.zshrc文件中有以下内容:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

我添加了用于修复原始Java版本的问题,但这似乎也没有更改Javac。

因此,在运行命令“哪个Java”和“哪个Javac”之后,我得到了:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

/usr/bin/javac

我认为这里有一些有趣的东西,对吗?但这基本上是我卡住的地方。我什至不确定这是否是问题,但这是我认为我只是在做一些愚蠢的事情而没有意识到这一点,

大声笑了任何帮助!

so I'm basically trying to run my ionic app on an android device, and the command "ionic cordova run android --device" get as far as telling me an error occurred due to:

Requirements check failed for JDK 1.8.x! Detected version: 16.0.0
Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.

So, after verifying which java versions I had and successfully changing the version to a 1.8.X, so when I run java -version, it returns:

java version "1.8.0_251"

However, running "ionic cordova run android --device" again, it returns the same original error:

 Requirements check failed for JDK 1.8.x! Detected version: 16.0.0
    Check your ANDROID_SDK_ROOT / JAVA_HOME / PATH environment variables.

After some more research, I realized that the javac version of it, tells me another version, and it needs to be same I believe. So when I run "javac -version", I get:

javac 16

So... I couldn't figure out how to change the javac version to be the same as java, the only thing I figure is that it could be something with PATH, but the topics get a bit confusing as I'm not sure what to do next?

I have in my .zshrc file the following:

export JAVA_HOME=`/usr/libexec/java_home -v 1.8`

Which I added to fix the original java version issue, but that didn't seem to have changed the javac as well.

So after running the commands "which java" and "which javac" respectively, I get:

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

/usr/bin/javac

I assume there's something funny in here, huh? But this is basically where I'm stuck. I'm not even sure if this is the issue, but it's one of those things I think I'm just doing something stupid without realising it lol

Any help is greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烛影斜 2025-02-19 03:28:43

目标

您描述的是您想要“ Java”和“ Javac”才能解决JDK 1.8。从那里,您将可以使用离子Cordova做事。

起点

是您运行的各种命令,以及它们的输出(我更改了格式,使其看起来像正在运行的实际命令,并且输出):

  • java编译器(“ Javac”)适用于JDK 16,并且生活在/usr/bin/javac(可能是另一个位置的别名)。

     %javac -version
    Javac 16
    
    %javac
    /usr/bin/javac
     
  • java运行时 - 启动Java虚拟机的东西 - 在其他地方解决
    总共 - /Library/Internet Plug-ins /... - 并以1.8版而不是16:

    显示

     %java
    /library/Internet Plugins/javaappletplugin.plugin/contents/home/bin/java
    
    %java -version
    Java版本“ 1.8.0_251”
     

外卖。

  • 一些 bin
  • 您在“/library/Internet ..”上分别安装了一些东西 - 这很可能是 jre(不是jdk),IS 1.8

fix

install jdk 1.8 - 这将为您提供一个编译器和运行时。

如果您看到以上其他任何内容,其他事情正在进行,我们将需要查看更多详细信息,包括从上述步骤中进行的任何输出。

Goal

You are describing that you want "java" and "javac" to both resolve to JDK 1.8. From there, you'll be able to use ionic cordova to do things.

Starting point

Here are various commands you've run, along with their output (I changed format to make it look like actual commands being run, and the output):

  • Java compiler ("javac") is for JDK 16, and lives at /usr/bin/javac (which might be an alias to another location).

    % javac -version
    javac 16
    
    % which javac
    /usr/bin/javac
    
  • Java runtime – the thing which starts the Java Virtual Machine – is resolving somewhere else
    altogether – /Library/Internet Plug-Ins/... – and shows up as version 1.8, not 16:

    % which java
    /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
    
    % java -version
    java version "1.8.0_251"
    

A few takeaways..

  • You have JDK 16 installed, resolving to /usr/bin
  • You have something separately installed at "/Library/Internet.." – this is most likely a JRE (not a JDK), and is version 1.8

Fix

Install JDK 1.8 – this will give you a compiler and runtime that are both version 1.8

  • Follow download steps here: https://www.oracle.com/java/technologies/downloads/#java8 Once installed, you should be able to switch to using JDK 1.8, and confirm versions of both the compiler (javac) and the runtime (java) binaries.

  • There are various ways to set JAVA_HOME and manage multiple JDK installs – this is the simplest way to just get past the issue you're facing: set JAVA_HOME manually. This will be system dependent, but below is an example from my local system.

    % export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home 
    
  • Verify that "java" resolves to your new 1.8 install:

    % java -version
    java version "1.8.0_341"
    Java(TM) SE Runtime Environment (build 1.8.0_341-b10)
    Java HotSpot(TM) 64-Bit Server VM (build 25.341-b10, mixed mode)
    
  • Verify that "javac" also resolves to your new 1.8 install:

    % javac -version
    javac 1.8.0_341
    

If you see anything other than above, something else is going on, and we would need to see more details, including whatever output happened from following the above steps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文