【问题标题】:Android maven misses my classes from the jarAndroid maven 错过了我在 jar 中的课程
【发布时间】:2014-07-02 11:06:15
【问题描述】:

我正在使用

编译我的 Android 应用

mvn 全新安装

当我查看生成的 jar 时,我的应用程序类丢失了,所以我在另一个测试项目中的 junit 测试将无法编译。

知道我需要做什么才能将所有 *.class 文件添加到 .m2\repository\com\twenty71\jenkinsApp3\1.0.0-SNAPSHOTjar\jenkinsApp3-1.0.0-SNAPSHOT.jar 吗?

mvn 构建的应用程序运行良好,所以只是 jar 有问题。

这是我的 pom.xml 文件:

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0

<groupId>com.twenty71</groupId>
<artifactId>jenkinsApp3</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>apk</packaging>
<name>jenkinsApp3</name>

<dependencies>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v7-appcompat</artifactId>
        <version>19.1.0</version>
        <type>apklib</type>
    </dependency>
    <dependency>
        <groupId>android.support</groupId>
        <artifactId>compatibility-v7-appcompat</artifactId>
        <version>19.1.0</version>
        <type>jar</type>
    </dependency>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>support-v4</artifactId>
        <version>r7</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <version>3.9.0-rc.1</version>
            <configuration>
                <sdk>
                    <platform>19</platform>
                </sdk>
                <deleteConflictingFiles>true</deleteConflictingFiles>
                <undeployBeforeDeploy>true</undeployBeforeDeploy>
            </configuration>
            <extensions>true</extensions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>

            </configuration>
        </plugin>
    </plugins>
</build>

【问题讨论】:

    标签: java android maven pom.xml


    【解决方案1】:

    请检查一下你的文件夹结构,之前我也遇到过这个问题。 Maven 采用 /src/main/java/ 结构。
    首先尝试通过命令创建一个maven项目:

    $ mvn archetype:generate -DgroupId=com.abc.xy. -DartifactId=projectName -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=true.
    

    "-DinteractiveMode=true"

    通过这个,您可以选择 maven 支持 Android 的文件夹结构(我以前从未使用过 android,所以不了解它的结构)
    然后,这里 Maven 将为您获取文件夹结构,只需将您的 .java 文件放在其 /src/main/java/ 文件夹中,然后再次构建您的项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多