ここから Robolectric サンプル コードをダウンロードし、Android スタジオでテストしています。このリンクに記載されている手順に従いました。パスは pom.xml ファイルに記載する必要があります。それが正確に何であるかはわかりません。これは私の pom.xml です:
http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
</parent>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectricsample</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>RobolectricSample app</name>
<description>Sample project demonstrating use of the Robolectric Android testing project.</description>
<url>https://github.com/pivotal/RobolectricSample</url>
<properties>
<robolectric.version>2.0</robolectric.version>
</properties>
<dependencies>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>3.0</version>
<classifier>no_aop</classifier>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>${robolectric.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6)-->
<platform>17</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<exclude>**/Test*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<scm>
<url>git@github.com:pivotal/RobolectricSample.git</url>
<connection>scm:git:git://github.com/pivotal/RobolectricSample.git</connection>
<developerConnection>scm:git:git@github.com:pivotal/RobolectricSample.git</developerConnection>
</scm>
<developers>
<developer>
<id>tyler</id>
<name>Tyler Schultz</name>
<email>tyler@pivotallabs.com</email>
<organization>Pivotal Labs</organization>
<organizationUrl>http://pivotallabs.com/</organizationUrl>
<roles>
<role>Project Owner</role>
<role>Developer</role>
</roles>
<timezone>PST/PDT</timezone>
</developer>
<developer>
<id>phil</id>
<name>Phil Goodwin</name>
<email>phil@pivotallabs.com</email>
<organization>Pivotal Labs</organization>
<organizationUrl>http://pivotallabs.com/</organizationUrl>
<roles>
<role>Developer</role>
</roles>
<timezone>PST/PDT</timezone>
</developer>
<developer>
<id>joemoore</id>
<name>Joe Moore</name>
<email>joe@pivotallabs.com</email>
<organization>Pivotal Labs</organization>
<organizationUrl>http://pivotallabs.com/</organizationUrl>
<roles>
<role>Developer</role>
</roles>
<timezone>EST/EDT</timezone>
</developer>
</developers>
<licenses>
<license>
<name>MIT license</name>
<comments>
The MIT License
Copyright (c) 2011 Pivotal Labs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</comments>
</license>
</licenses>
私が得ているエラーは次のとおりです。
"C:\Program Files\Java\jdk1.7.0_45\bin\java" "-Dmaven.home=C:\Program Files (x86)\Android\apache-maven-3.0.5" "-Dclassworlds.conf=C :\Program Files (x86)\Android\apache-maven-3.0.5\bin\m2.conf" -Didea.launcher.port=7534 -Didea.launcher.bin.path=C:\Users\ashish\AppData\ Local\Android\android-studio\bin -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\Android\apache-maven-3.0.5\boot\plexus-classworlds-2.4.jar;C :\Users\ashish\AppData\Local\Android\android-studio\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher テスト
プロジェクト robolectricsample でゴール com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources (default-generate-sources) を実行できませんでした: Android SDK パスが見つかりませんでした。... または ... を使用して pom ファイルのプラグイン構成セクションで構成するか、コマンドラインで -Dandroid.sdk.path=... を使用するか、環境変数 ANDROID_HOME -> [Help 1] [ ERROR] [ERROR] エラーの完全なスタック トレースを表示するには、-e スイッチを指定して Maven を再実行します。[エラー] -X スイッチを使用して Maven を再実行し、完全なデバッグ ログを有効にします。[エラー] [エラー] エラーと考えられる解決策の詳細については、次の記事を参照してください: [エラー] [ヘルプ 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
プロセスは終了コード 1 で終了しました
私を助けてください、事前に感謝します