简体   繁体   English

Android FEST无法针对IDE中的单元测试正确编译

[英]Android FEST not compiling properly for unit tests in IDE

For some reason, Android Studio is not properly compiling the Android FEST library (?). 由于某些原因,Android Studio无法正确编译Android FEST库(?)。

This line, 这条线

assertThat(someView).isNotVisible();

causes this exception to be thrown: 导致抛出此异常:

java.lang.UnsupportedClassVersionError: org/fest/assertions/api/ANDROID : Unsupported major.minor version 51.0

and the import that i used is: import static org.fest.assertions.api.ANDROID.assertThat; 我使用的导入是: import static org.fest.assertions.api.ANDROID.assertThat;

What's going on? 这是怎么回事?

Oh, and it should be noted that the gradle task to run unit tests run just fine (but just not for IDE). 哦,应该指出的是,运行单元测试的gradle任务运行得很好(但不适用于IDE)。

THis means that the library was compiled with a later version of Java than what you're using to do builds in the IDE. 这意味着该库是使用比您在IDE中进行构建的Java版本更高的Java编译的。 v51.0 is Java 7, so you need to have JDK 7 available and set Android Studio to use it via Project Structure > SDK location. v51.0是Java 7,因此您需要拥有JDK 7并通过Project Structure> SDK location设置Android Studio以使用它。

Note that you don't need to run the IDE itself using Java 7 if you don't want, and you don't have to turn on Java 7 compatibility in your projects; 注意,如果不需要,您不需要使用Java 7运行IDE本身,也不必在项目中打开Java 7兼容性。 you just need to use Java 7 to do the builds themselves. 您只需要使用Java 7自己进行构建即可。

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

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