在IntelliJ中运行我的robolectric测试时,我得到:
Warning: an error occurred while binding shadow class: ShadowGeoPoint
Warning: an error occurred while binding shadow class: ShadowItemizedOverlay
Warning: an error occurred while binding shadow class: ShadowMapController
Warning: an error occurred while binding shadow class: ShadowMapActivity
Warning: an error occurred while binding shadow class: ShadowMapView
Warning: an error occurred while binding shadow class: ShadowOverlayItem
WARNING: Unable to find path to Android SDK
java.lang.RuntimeException: java.lang.NullPointerException
at com.xtremelabs.robolectric.res.ResourceLoader.init(ResourceLoader.java:158)
at com.xtremelabs.robolectric.res.ResourceLoader.setLayoutQualifierSearchPath(ResourceLoader.java:599)
at com.xtremelabs.robolectric.RobolectricTestRunner.setupApplicationState(RobolectricTestRunner.java:367)
at com.xtremelabs.robolectric.RobolectricTestRunner.internalBeforeTest(RobolectricTestRunner.java:311)
at com.xtremelabs.robolectric.RobolectricTestRunner.methodBlock(RobolectricTestRunner.java:278)
at ...
ANDROID_HOME已设置,但InteliJ似乎找不到它。
答案 0 :(得分:2)
通过在项目的根目录中运行以下内容,在sdk.dir
文件中设置local.properties
:
$ android update project -p .
设置local.properties
文件是一种适用于大多数IDE的解决方案,因为您无需担心传递环境变量。
我是从Unable to find Android SDK
得到的。您可以尝试其他几种选择。
答案 1 :(得分:0)
注意:您可以在JUnit默认设置中添加它,这样您就不必为每个测试类做到这一点