0

我已经从这里下载了 Robolectric 示例代码,我正在 Android Studio 上对其进行测试。我按照此链接中提到的步骤进行操作。必须在 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 以启用完整的调试日志记录。[ERROR] [ERROR] 有关错误和可能的解决方案的更多信息,请阅读以下文章: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

进程以退出代码 1 结束

请帮帮我,谢谢提前

4

0 回答 0