Selendroid - ANDROID_HOME即使在设置后也未找到

时间:2014-05-19 06:32:19

标签: android automation mobile-website selendroid

我正在尝试为移动网站运行Selendroid测试但是当我运行测试时,我得到例外说法:

    May 19, 2014 11:48:59 AM io.selendroid.SelendroidLauncher launchServer
INFO: Starting selendroid-server port 4444
May 19, 2014 11:48:59 AM io.selendroid.SelendroidLauncher launchServer
SEVERE: Error occurred while building server: io.selendroid.exceptions.SelendroidException: Environment variable 'ANDROID_HOME' was not found!
java.lang.RuntimeException: io.selendroid.exceptions.SelendroidException: Environment variable 'ANDROID_HOME' was not found!
    at io.selendroid.server.model.SelendroidStandaloneDriver.initApplicationsUnderTest(SelendroidStandaloneDriver.java:142)
    at io.selendroid.server.model.SelendroidStandaloneDriver.<init>(SelendroidStandaloneDriver.java:80)
    at io.selendroid.server.SelendroidStandaloneServer.initializeSelendroidServer(SelendroidStandaloneServer.java:91)
    at io.selendroid.server.SelendroidStandaloneServer.<init>(SelendroidStandaloneServer.java:65)
    at io.selendroid.SelendroidLauncher.launchServer(SelendroidLauncher.java:49)
    at io.selendroid.SelendroidLauncher.launchSelendroid(SelendroidLauncher.java:73)
    at com.pb.crawler.MobileWebTest.startSelendroidServer(MobileWebTest.java:86)
    at com.pb.crawler.MobileWebTest.main(MobileWebTest.java:27)
Caused by: io.selendroid.exceptions.SelendroidException: Environment variable 'ANDROID_HOME' was not found!
    at io.selendroid.android.AndroidSdk.androidHome(AndroidSdk.java:97)
    at io.selendroid.android.AndroidSdk.platformToolsHome(AndroidSdk.java:86)
    at io.selendroid.android.AndroidSdk.aapt(AndroidSdk.java:39)
    at io.selendroid.android.impl.DefaultAndroidApp.deleteFileFromWithinApk(DefaultAndroidApp.java:102)
    at io.selendroid.builder.SelendroidServerBuilder.deleteFileFromAppSilently(SelendroidServerBuilder.java:116)
    at io.selendroid.builder.SelendroidServerBuilder.resignApp(SelendroidServerBuilder.java:125)
    at io.selendroid.server.model.SelendroidStandaloneDriver.initApplicationsUnderTest(SelendroidStandaloneDriver.java:138)
    ... 7 more
Exception in thread "main" java.lang.RuntimeException: io.selendroid.exceptions.SelendroidException: Environment variable 'ANDROID_HOME' was not found!
    at io.selendroid.server.model.SelendroidStandaloneDriver.initApplicationsUnderTest(SelendroidStandaloneDriver.java:142)
    at io.selendroid.server.model.SelendroidStandaloneDriver.<init>(SelendroidStandaloneDriver.java:80)
    at io.selendroid.server.SelendroidStandaloneServer.initializeSelendroidServer(SelendroidStandaloneServer.java:91)
    at io.selendroid.server.SelendroidStandaloneServer.<init>(SelendroidStandaloneServer.java:65)
    at io.selendroid.SelendroidLauncher.launchServer(SelendroidLauncher.java:49)
    at io.selendroid.SelendroidLauncher.launchSelendroid(SelendroidLauncher.java:73)
    at com.pb.crawler.MobileWebTest.startSelendroidServer(MobileWebTest.java:86)
    at com.pb.crawler.MobileWebTest.main(MobileWebTest.java:27)
Caused by: io.selendroid.exceptions.SelendroidException: Environment variable 'ANDROID_HOME' was not found!
    at io.selendroid.android.AndroidSdk.androidHome(AndroidSdk.java:97)
    at io.selendroid.android.AndroidSdk.platformToolsHome(AndroidSdk.java:86)
    at io.selendroid.android.AndroidSdk.aapt(AndroidSdk.java:39)
    at io.selendroid.android.impl.DefaultAndroidApp.deleteFileFromWithinApk(DefaultAndroidApp.java:102)
    at io.selendroid.builder.SelendroidServerBuilder.deleteFileFromAppSilently(SelendroidServerBuilder.java:116)
    at io.selendroid.builder.SelendroidServerBuilder.resignApp(SelendroidServerBuilder.java:125)
    at io.selendroid.server.model.SelendroidStandaloneDriver.initApplicationsUnderTest(SelendroidStandaloneDriver.java:138)
    ... 7 more

虽然我的ANDROID_HOME已经设置为回显,但命令给了我正确的路径。

~ vshukla$ echo $JAVA_HOME
 /Library/Java/Home

~ vshukla$ echo $ANDROID_HOME
/Users/vshukla/AndroidSDK/sdk

我无法理解为什么会这样。请帮忙。

1 个答案:

答案 0 :(得分:0)

它对我有用

  1. 打开以编辑/etc/launchd.conf文件
  2. 添加以下内容:setenv ANDROID_HOME / location android_home
  3. 重新启动它应该可以工作。
  4. 我希望它有所帮助!!