无法使用具有依赖项的maven在Android检测测试中解析超类

时间:2014-04-05 23:40:05

标签: java android maven robotium instrumentation

我的Android应用程序是mavenized,我想包括仪器。 我已经决定创建另一个专门用于此的应用程序。

main-app
|\android-app
| |pom.xml
|\android-instrumentation
| |pom.xml
|pom.xml

正确编译和部署Android应用

Instrumentation应用程序正确编译但logcat显示许多异常,如下所示。 apk中没有一些类?

    04-05 15:29:59.550: W/dalvikvm(1419): Unable to resolve superclass of Lorg/gots/IntentIntegratorSupportV4; (262)
04-05 15:29:59.550: W/dalvikvm(1419): Link of class 'Lorg/gots/IntentIntegratorSupportV4;' failed
04-05 15:29:59.580: W/dalvikvm(1419): Unable to resolve superclass of Lorg/gots/IntentIntegratorSupportV4; (227)
04-05 15:29:59.580: W/dalvikvm(1419): Link of class 'Lorg/gots/IntentIntegratorSupportV4;' failed
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419): Cannot load class. Make sure it is in your apk. Class name: 'org.gots.IntentIntegratorSupportV4'. Message: org.gots.IntentIntegratorSupportV4
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419): java.lang.ClassNotFoundException: org.gots.IntentIntegratorSupportV4
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at java.lang.Class.classForName(Native Method)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at java.lang.Class.forName(Class.java:217)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.ClassPathPackageInfoSource.createPackageInfo(ClassPathPackageInfoSource.java:88)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.ClassPathPackageInfoSource.access$000(ClassPathPackageInfoSource.java:39)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:50)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.ClassPathPackageInfoSource$1.load(ClassPathPackageInfoSource.java:47)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.SimpleCache.get(SimpleCache.java:31)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.ClassPathPackageInfoSource.getPackageInfo(ClassPathPackageInfoSource.java:72)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.ClassPathPackageInfo.getSubpackages(ClassPathPackageInfo.java:48)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.ClassPathPackageInfo.addTopLevelClassesTo(ClassPathPackageInfo.java:61)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.ClassPathPackageInfo.getTopLevelClassesRecursive(ClassPathPackageInfo.java:55)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.suitebuilder.TestGrouping.testCaseClassesInPackage(TestGrouping.java:156)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.suitebuilder.TestGrouping.addPackagesRecursive(TestGrouping.java:117)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.suitebuilder.TestSuiteBuilder.includePackages(TestSuiteBuilder.java:102)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:366)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3920)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.app.ActivityThread.access$1300(ActivityThread.java:123)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.os.Looper.loop(Looper.java:137)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at android.app.ActivityThread.main(ActivityThread.java:4424)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at java.lang.reflect.Method.invoke(Method.java:511)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at dalvik.system.NativeStart.main(Native Method)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419): Caused by: java.lang.NoClassDefFoundError: org/gots/IntentIntegratorSupportV4
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     ... 26 more
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419): Caused by: java.lang.ClassNotFoundException: org.gots.IntentIntegratorSupportV4
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
04-05 15:29:59.610: W/ClassPathPackageInfoSource(1419):     ... 26 more

似乎我的apk中缺少或包含了一些libs,我不明白。

主app pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.gots</groupId>
    <artifactId>gardening-manager</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>
  <artifactId>gardening-manager-android</artifactId>
  <packaging>apk</packaging>
  <version>0.28-SNAPSHOT</version>
  <name>Gardening Manager Android</name>
  <properties>
    <android.version>4.2</android.version>
    <android.platform>17</android.platform>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <compatibility.version>18</compatibility.version>
  </properties>
  <repositories>
    <repository>
      <id>gardening-manager-maven</id>
      <url>http://github.com/artmoni/gardening-manager-maven/raw/master</url>
    </repository>
    <repository>
      <id>jakewharton</id>
      <url>http://r.jakewharton.com/maven/release/</url>
    </repository>
    <repository>
      <id>google-api-services</id>
      <url>http://mavenrepo.google-api-java-client.googlecode.com/hg</url>
    </repository>
    <repository>
      <id>public-releases</id>
      <url>https://maven.nuxeo.org/nexus/content/repositories/public-releases/</url>
    </repository>
    <repository>
      <id>public-snapshots</id>
      <url>https://maven-us.nuxeo.org/nexus/content/repositories/public-snapshots/</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
    <repository>
      <id>sonatype-oss-public</id>
      <url>https://oss.sonatype.org/content/groups/public/</url>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  </repositories>
  <dependencies>
    <dependency>
      <groupId>io.oauth</groupId>
      <artifactId>oauth-android</artifactId>
      <version>0.1</version>
    </dependency>
    <dependency>
      <groupId>android</groupId>
      <artifactId>android</artifactId>
      <version>4.2.2_r2</version>
      <scope>provided</scope>
    </dependency>
    <!-- <dependency> <groupId>com.actionbarsherlock</groupId> <artifactId>actionbarsherlock</artifactId> 
      <version>4.4.0</version> <type>apklib</type> </dependency> -->
    <dependency>
      <groupId>android.support</groupId>
      <artifactId>compatibility-v7-appcompat</artifactId>
      <version>${compatibility.version}</version>
      <type>apklib</type>
    </dependency>
    <dependency>
      <groupId>android.support</groupId>
      <artifactId>compatibility-v7-appcompat</artifactId>
      <version>${compatibility.version}</version>
      <type>jar</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.android.analytics</groupId>
      <artifactId>analytics</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.android.admob</groupId>
      <artifactId>admob</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.zxing</groupId>
      <artifactId>android-integration</artifactId>
      <scope>provided</scope>
    </dependency>
    <!-- ********* NUXEO INTEGRATION BEGIN********* -->
    <dependency>
      <groupId>org.nuxeo.android</groupId>
      <artifactId>nuxeo-android-connector</artifactId>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>android.support</groupId>
          <artifactId>compatibility-v7-appcompat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.nuxeo.android</groupId>
      <artifactId>nuxeo-android-connector-ui</artifactId>
      <scope>provided</scope>
      <type>apklib</type>
      <exclusions>
        <exclusion>
          <groupId>android.support</groupId>
          <artifactId>compatibility-v7-appcompat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.google.android.gms</groupId>
      <artifactId>google-play-services</artifactId>
      <version>12</version>
      <type>apklib</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.android.gms</groupId>
      <artifactId>google-play-services</artifactId>
      <version>12</version>
      <type>jar</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.api-client</groupId>
      <artifactId>google-api-client</artifactId>
      <version>1.17.0-rc</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <artifactId>xpp3</artifactId>
          <groupId>xpp3</groupId>
        </exclusion>
        <exclusion>
          <artifactId>httpclient</artifactId>
          <groupId>org.apache.httpcomponents</groupId>
        </exclusion>
        <exclusion>
          <artifactId>junit</artifactId>
          <groupId>junit</groupId>
        </exclusion>
        <exclusion>
          <artifactId>android</artifactId>
          <groupId>com.google.android</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.google.api-client</groupId>
      <artifactId>google-api-client-android</artifactId>
      <version>1.17.0-rc</version>
      <scope>provided</scope>
    </dependency>
    <!-- ********* SOCIALAUTH INTEGRATION END********* -->
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.9</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <version>3.9.0-rc.1</version>
        <extensions>true</extensions>
        <configuration>
          <sdk>
            <path>${sdk.path}</path>
            <platform>${android.platform}</platform>
          </sdk>
          <nativeLibrariesDirectory>ignored</nativeLibrariesDirectory>
          <deleteConflictingFiles>true</deleteConflictingFiles>
          <undeployBeforeDeploy>false</undeployBeforeDeploy>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <!-- <profile> -->
    <!-- <id>emma</id> -->
    <!-- <build> -->
    <!-- <plugins> -->
    <!-- <plugin> -->
    <!-- <groupId>com.jayway.maven.plugins.android.generation2</groupId> -->
    <!-- <artifactId>android-maven-plugin</artifactId> -->
    <!-- <configuration> -->
    <!-- emma start -->
    <!-- <emma> -->
    <!-- <enable>true</enable> -->
    <!-- <classFolders>${project.basedir}/target/classes/</classFolders> -->
    <!-- <outputMetaFile>${project.basedir}/target/emma/coverage.em</outputMetaFile> -->
    <!-- </emma> -->
    <!-- emma stop -->
    <!-- <dex> -->
    <!-- <noLocals>true</noLocals> -->
    <!-- must be set for emma -->
    <!-- </dex> -->
    <!-- </configuration> -->
    <!-- <extensions>true</extensions> -->
    <!-- </plugin> -->
    <!-- </plugins> -->
    <!-- </build> -->
    <!-- </profile> -->
    <profile>
      <id>release</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jarsigner-plugin</artifactId>
            <executions>
              <execution>
                <id>signing</id>
                <goals>
                  <goal>sign</goal>
                  <goal>verify</goal>
                </goals>
                <phase>package</phase>
                <inherited>true</inherited>
                <configuration>
                  <removeExistingSignatures>true</removeExistingSignatures>
                  <archiveDirectory />
                  <includes>
                    <include>${project.build.directory}/${project.artifactId}.apk</include>
                  </includes>
                  <keystore>${sign.keystore}</keystore>
                  <alias>${sign.alias}</alias>
                  <storepass>${sign.storepass}</storepass>
                  <keypass>${sign.keypass}</keypass>
                  <verbose>true</verbose>
                  <arguments>
                    <argument>-sigalg</argument>
                    <argument>MD5withRSA</argument>
                    <argument>-digestalg</argument>
                    <argument>SHA1</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>maven-android-plugin</artifactId>
            <inherited>true</inherited>
            <configuration>
              <sign>
                <debug>false</debug>
              </sign>
              <zipalign>
                <verbose>true</verbose>
                <inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk>
                <outputApk>${project.build.directory}/${project.artifactId}-signed-aligned.apk 
                </outputApk>
              </zipalign>
            </configuration>
            <executions>
              <execution>
                <id>alignApk</id>
                <phase>package</phase>
                <goals>
                  <goal>zipalign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  <scm>
    <connection>scm:git:https://github.com/artmoni/gardening-manager-android</connection>
    <developerConnection>scm:git:https://github.com/artmoni/gardening-manager-android</developerConnection>
    <url>https://github.com/artmoni/gardening-manager-android</url>
  </scm>
</project>

仪器测试pom.xml

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://maven.apache.org/POM/4.0.0"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.gots</groupId>
    <artifactId>gardening-manager</artifactId>
    <version>1.0.0-SNAPSHOT</version>
  </parent>
  <artifactId>gardening-manager-test</artifactId>
  <packaging>apk</packaging>
  <version>0.28-SNAPSHOT</version>
  <name>Gardening Manager Instrumentation</name>
  <properties>
    <android.sdk.path>MY SDK PATH</android.sdk.path>
    <android.version>4.2</android.version>
    <android.platform>16</android.platform>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.gots</groupId>
      <artifactId>gardening-manager-android</artifactId>
      <version>0.28-SNAPSHOT</version>
      <type>jar</type>

    </dependency>
    <dependency>
      <groupId>org.gots</groupId>
      <artifactId>gardening-manager-android</artifactId>
      <version>0.28-SNAPSHOT</version>
      <type>apk</type>

    </dependency>
    <dependency>
      <groupId>android.support</groupId>
      <artifactId>compatibility-v7-appcompat</artifactId>
      <version>${compatibility.version}</version>
      <type>apklib</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>android.support</groupId>
      <artifactId>compatibility-v7-appcompat</artifactId>
      <version>${compatibility.version}</version>
      <type>jar</type>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>android.support</groupId>
      <artifactId>compatibility-v4</artifactId>
      <scope>provided</scope>
    </dependency>
    <!-- ********* TEST ********* -->
    <dependency>
      <groupId>com.jayway.android.robotium</groupId>
      <artifactId>robotium-solo</artifactId>
      <version>4.3</version>

    </dependency>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android</artifactId>
      <scope>provided</scope>

    </dependency>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android-test</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>${project.artifactId}</finalName>
    <sourceDirectory>src</sourceDirectory>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.jayway.maven.plugins.android.generation2</groupId>
          <artifactId>android-maven-plugin</artifactId>
          <version>3.9.0-rc.1</version>
          <extensions>true</extensions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <configuration>
          <sdk>
            <path>${sdk.path}</path>
            <platform>16</platform>
          </sdk>
          <emulator>
            <avd>Device</avd>
            <wait>2000</wait>
          </emulator>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

此时,我使用Maven 3.1.1进行编译

提前谢谢,问题和应用程序测试失去了很多时间。

0 个答案:

没有答案