在Android Studio下学习怎么执行单元测试,现总结如下:
  1. https://coderwall.com/p/ybds4w
  http://blog.futurice.com/android_unit_testing_in_ides_and_ci_environments
  2. 出现问题如下:
Exception in thread "main" java.lang.NoClassDefFoundError: junit/textui/ResultPrinter
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)
Caused by: java.lang.ClassNotFoundException: junit.textui.ResultPrinter
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
... 3 more
  原因为调用的junit  android-studiopluginsjunitlibjunit-rt.jar 下没有junit/textui/ResultPrinter 这个class文件,怎么解决呢????
  3. com.google.inject的maven配置
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>1.0</version>
</dependency>
  4. android-4.0.1.2.jar Maven配置
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.0.1.2</version>
</dependency>
  5. 用gradle编译项目时出错:
  Could not create plugin of type 'AppPlugin'
  解决方法:
  classpath 'com.android.tools.build:gradle:0.7.0' 改为 classpath 'com.android.tools.build:gradle:0.7.3'
  6. 用gradle 同步工程出现错误如下:
  Unable to load class 'org.gradle.api.artifacts.result.ResolvedComponentResult'
  解决方法:
  classpath 'com.android.tools.build:gradle:0.7.3'