1

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 はそれを見つけられないようです。

4

2 に答える 2

2

プロジェクトのルート ディレクトリで次のコマンドを実行してsdk.dir、ファイルに を設定します。local.properties

$ android update project -p .

ファイルのセットアップlocal.propertiesは、環境変数が渡されることを心配する必要がないため、ほとんどの IDE で機能するソリューションです。

からこれをもらいましたUnable to find Android SDK。他にもいくつかのオプションがあります。

于 2013-04-06T10:58:14.307 に答える
0
  • 実行構成に移動します (実行 -> EditConfigurations..)
  • 左側 (JUnit の下) からテストを選択します。
  • 構成タブで、環境変数セクションに移動し、SDK を指す環境変数 ANDROID_HOME を追加します。
  • テストを再度適用、ビルド、実行する

注:これをJUnitのデフォルト設定に追加できるため、テストクラスごとに行う必要はありません

于 2013-04-06T16:33:39.267 に答える