Maven android:运行错误:Activity类不存在

时间:2013-06-05 17:45:12

标签: android maven deployment pom.xml

我准备了以下 pom.xml 来为opensource project MapChange启用Maven构建:

<?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>

  <artifactId>mapchange</artifactId>
  <groupId>com.bricolsoftconsulting</groupId>
  <version>0.1.0-SNAPSHOT</version>
  <packaging>apklib</packaging>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!-- Plugins -->
    <jdk.version>1.6</jdk.version>
    <api.platform>7</api.platform>
    <android-maven-plugin.version>3.6.0</android-maven-plugin.version>
    <maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>

    <!-- Dependencies -->
    <android.version>4.1.1.4</android.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.google.android</groupId>
      <artifactId>android</artifactId>
      <scope>provided</scope>
      <version>${android.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>android-maven-plugin</artifactId>
        <version>${android-maven-plugin.version}</version>
        <extensions>true</extensions>
        <configuration>
          <sdk>
            <platform>${api.platform}</platform>
          </sdk>
          <undeployBeforeDeploy>true</undeployBeforeDeploy>
          <lazyLibraryUnpack>true</lazyLibraryUnpack>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
          <source>${jdk.version}</source>
          <target>${jdk.version}</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

当我运行mvn clean install时,构建成功完成。


但是当我使用mvn clean install android:deploy android:run部署并运行应用到设备时,无法找到活动。

[ERROR] Failed to execute goal com.jayway.maven.plugins.android.generation2: \
        android-maven-plugin:3.6.0:run (default-cli) on project mapchange: \
        Unable to run launcher Activity: Starting: \
           Intent { cmp=com.bricolsoftconsulting.mapchange/.MyMapActivity }
[ERROR] Error type 3
[ERROR] Error: Activity class \
        {com.bricolsoftconsulting.mapchange/com.bricolsoftconsulting \
                 .mapchange.MyMapActivity} does not exist.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven \
        with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, \
        please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/ \
        MAVEN/MojoFailureException

请注意我不熟悉使用Maven, pom.xml 可能包含错误配置

1 个答案:

答案 0 :(得分:0)

最后,我能够设置一个多模块Maven项目。请在此处找到当前(工作)实施: