mobile-dev-inc / maestro

Painless Mobile UI Automation
https://maestro.mobile.dev/
Apache License 2.0
5.76k stars 265 forks source link

I can't run " maestro test {path of file yaml} " after install Java for iOS Developer #135

Closed JARNBOY closed 2 years ago

JARNBOY commented 2 years ago

I download java because when run maestro test /Users/paponsupamongkonchai/MaestroYAML/flow_ios_test.yaml first time log of terminal introduce downlod Java for run command of maestro

Then download and install Java so I run again in terminal maestro test /Users/paponsupamongkonchai/MaestroYAML/flow_ios_test.yaml it's show this message about version Java not support in Java version 55.0

=======See Log Below=======

paponsupamongkonchai@Papons-MacBook-Pro ~ % maestro test /Users/paponsupamongkonchai/MaestroYAML/flow_ios_test.yaml
Exception in thread "main" java.lang.UnsupportedClassVersionError: idb/CompanionServiceGrpc has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at ios.idb.IdbIOSDevice.<init>(IdbIOSDevice.kt:58)
    at maestro.Maestro$Companion.ios(Maestro.kt:291)
    at maestro.Maestro$Companion.ios(Maestro.kt:287)
    at maestro.cli.util.MaestroFactory.createIos(MaestroFactory.kt:58)
    at maestro.cli.util.MaestroFactory.autoDetectPlatform(MaestroFactory.kt:66)
    at maestro.cli.util.MaestroFactory.createMaestro(MaestroFactory.kt:33)
    at maestro.cli.command.TestCommand.call(TestCommand.kt:58)
    at maestro.cli.command.TestCommand.call(TestCommand.kt:30)
    at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
    at picocli.CommandLine.access$1200(CommandLine.java:145)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
    at picocli.CommandLine.execute(CommandLine.java:2058)
    at maestro.cli.AppKt.main(App.kt:74)
dmitry-zaitsev commented 2 years ago

It seems that your version of Java is too old. Make sure that you are using Java 11 or higher.

You can install it by running brew install openjdk@11

JARNBOY commented 2 years ago

I try follow install it by running brew install openjdk@11 and try running brew reinstall openjdk@11 but is show same Exception Exception in thread "main" java.lang.UnsupportedClassVersionError: idb/CompanionServiceGrpc has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Screen Shot 2565-09-06 at 22 48 32

Can you suggest another solution for me?

dmitry-zaitsev commented 2 years ago

Interesting, could you try brew install java?

JARNBOY commented 2 years ago

I running brew install java is not help me.
Result when run maestro test /Users/paponsupamongkonchai/MaestroYAML/flow_ios_test.yaml show same issue about version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Screen Shot 2565-09-06 at 23 10 46

thank you for support tomorrow I will try fix again and I will update if I can fix this problem in this issue , But if you have another solution you post in issue I will try it sir haha.

Best regrad. Papon Supamongkonckonchai (JARNBOY)

maciejkrolik commented 2 years ago

I had the same issue and after Java update it worked :) As I can see in the screenshot you are still using Java 8. After executing all the commands above you probably have multiple Java versions installed in the system. Changing the default one should help.

JARNBOY commented 2 years ago

@maciejkrolik You can share step by step to change version java I try follow in stackoverflow but not change default java version.

JARNBOY commented 2 years ago

Finally I found solution fix this problem by change default java version. you can see solution in this Blog(https://medium.com/miro-engineering/how-to-switch-between-java-lts-versions-8-11-and-17-on-mac-cb6717d1272)

I will show you step by step for another had same issue after you download java.dmg from website .

  1. open terminal
  2. pastebrew install java -> until download success -> ok next.
  3. paste brew install openjdk -> it's install lastest jdk
  4. check version java -version -> if you see old version in my case show version old is1.8.0._ -> ok next.
  5. paste code this for change default java
    
    # version 18
    brew install openjdk@18
    sudo ln -sfn /usr/local/opt/openjdk@18/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-18.jdk

version 17

brew install openjdk@17 sudo ln -sfn /usr/local/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk

version 11

brew install openjdk@11 sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk

version 8

brew install openjdk@8 sudo ln -sfn /usr/local/opt/openjdk@8/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-8.jdk

6. when install all is success you paste this 

javahome() { unset JAVA_HOME export JAVA_HOME=$(/usr/libexec/java_home -v "$1"); java -version } alias j1.8='javahome 1.8' alias j11='javahome 11' alias j17='javahome 17' alias j18='javahome 18’

7.when enter done  you paste this
when install all is success you paste this

$ j18 openjdk version "18.0.2.1" 2022-09-07 OpenJDK Runtime Environment Homebrew (build 18.0.1+0) OpenJDK 64-Bit Server VM Homebrew (build 18.0.1+0, mixed mode, sharing) $ j17 openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment Homebrew (build 17.0.1+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.1+0, mixed mode, sharing) $ j11 openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment Homebrew (build 11.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode) $ j1.8 openjdk version "1.8.0_312" OpenJDK Runtime Environment (build 1.8.0_312-bre_2021_10_20_23_15-b00) OpenJDK 64-Bit Server VM (build 25.312-b00, mixed mode)


8. Set java_home if you never set for MacOS can select device current youcan see in (https://stackoverflow.com/questions/22842743/how-to-set-java-home-environment-variable-on-mac-os-x-10-9)

9. ok you restart device Macbook 

10. try run " maestro test {path of file yaml} " again.

<img width="965" alt="Screen Shot 2565-09-07 at 23 52 04" src="https://user-images.githubusercontent.com/51109993/188935425-141bd8a5-f335-4d2e-9100-88ced078ca86.png">
dmitry-zaitsev commented 2 years ago

@JARNBOY happy that it worked for you!

github-actions[bot] commented 3 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar problem, please file a new issue. Make sure to follow the template and provide all the information necessary to reproduce the issue. Thank you for helping keep us our issue tracker clean!