小白,刚开始用,新建了一个 AppiumTest 的类,运行报错如下,求教大神,是什么原因。

google 搜索结果说是项目 jdk 版本不匹配,反复更换 jdk 版本为 1.5、1.6,均还是提示以下错误,求解
谢谢各位的指导。

PS:本地 jdk 版本是 1.6

Exception in thread "main" java.lang.UnsupportedClassVersionError: io/appium/java_client/android/AndroidDriver : Unsupported major.minor version 51.0

代码
import io.appium.java_client.android.AndroidDriver;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

public class test {
public static void main(String[] args) throws MalformedURLException {

AndroidDriver driver;

File classpathRoot = new File(System.getProperty("user.dir"));
File appDir = new File(classpathRoot, "apps");
File app = new File(appDir, "BiliPlayer.apk");

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device", "Android");
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("platformVersion", "4.4");
capabilities.setCapability("platformName", "Android");

capabilities.setCapability("app", app.getAbsolutePath());

capabilities.setCapability("app-package", "tv.danmaku.bili");
capabilities.setCapability("app-activity", ".launcherActivity");

driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

System.out.println("App is launched");
driver.quit();
}
}

控制台错误信息
Exception in thread "main" java.lang.UnsupportedClassVersionError: io/appium/java_client/android/AndroidDriver : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at com.netfinworks.AppiumTest.test.main(test.java:32)


↙↙↙阅读原文可查看相关链接,并与作者交流