Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android APK在使用maven构建时缺少一些类_Android_Maven_Pom.xml - Fatal编程技术网

Android APK在使用maven构建时缺少一些类

Android APK在使用maven构建时缺少一些类,android,maven,pom.xml,Android,Maven,Pom.xml,这是一个重复的答案,但这个答案并不能解决我的问题 我的特定构建环境的一些背景: 我正在使用与示例项目一起使用的。该项目包括一个父级pom.xml,然后是三个子模块(项目)中每一个子模块的pom.xml。每个子模块都将父模块定义为父模块 当我在原始下载的项目上运行mvn clean install时,它会在手机上构建和安装/运行 但是我没有将源代码添加到Eclipse中,在Eclipse中mvn构建脚本不再工作(即apk更小,缺少类)运行良好 任何关于如何解决这个问题的想法都将不胜感激 这是父项目

这是一个重复的答案,但这个答案并不能解决我的问题

我的特定构建环境的一些背景:

我正在使用与示例项目一起使用的。该项目包括一个父级
pom.xml
,然后是三个子模块(项目)中每一个子模块的
pom.xml
。每个子模块都将父模块定义为父模块

当我在原始下载的项目上运行
mvn clean install
时,它会在手机上构建和安装/运行

但是我没有将源代码添加到Eclipse中,在Eclipse中mvn构建脚本不再工作(即apk更小,缺少类)运行良好

任何关于如何解决这个问题的想法都将不胜感激

这是父项目的
POM
文件,之后是应用项目的
POM
。很抱歉发布这么多代码,但我不确定问题出在哪里

更新对于面临类似问题的人,我已经开始在谷歌集团[Maven Android Developers]上进行转换。我可能会先在那里得到答案

<?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>
    <groupId>com.simpligility.android.morse</groupId>
    <artifactId>morseflash-parent</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>MorseFlash - Parent</name>

    <properties>
        <server_schema>http</server_schema>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.8.1</version>
            </dependency>
            <dependency>
                <groupId>com.google.android</groupId>
                <artifactId>android</artifactId>
                <version>2.3.1</version>
            </dependency>
            <dependency>
                <groupId>com.google.android</groupId>
                <artifactId>android-test</artifactId>
                <version>2.3.1</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>

        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-jarsigner-plugin</artifactId>
                    <version>1.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                    <artifactId>android-maven-plugin</artifactId>
                    <version>3.4.1</version>

                    <configuration>
                        <sdk>
                            <platform>10</platform>
                        </sdk>
                        <emulator>
                            <avd>23</avd>
                            <wait>10000</wait>
                            <!--<options>-no-skin</options> -->
                        </emulator>
                        <zipalign>
                            <verbose>true</verbose>
                        </zipalign>
                        <undeployBeforeDeploy>true</undeployBeforeDeploy>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>1.5</version>
                </plugin>
                <!--This plugin's configuration is used to store Eclipse m2e settings 
                    only. It has no influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                                        <artifactId>android-maven-plugin</artifactId>
                                        <versionRange>[3.2.0,)</versionRange>
                                        <goals>
                                            <goal>manifest-update</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <!-- the standard profile runs the instrumentation tests -->
            <id>standard</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <modules>
                <module>morse-lib</module>
                <module>morseflash-app</module>
                <module>morseflash-instrumentation</module>
            </modules>
            <properties>
                <!-- when i will try to enter this address the app will start :) -->
                <!-- for development i want to use my local host -->
                <!-- server schema is defined globally for all profiles but can be overridden
                    here for the local profile -->
                <!-- this properties are good for all the maven modules -->
                <server_host>192.168.1.12</server_host>
                <server_path></server_path>
            </properties>
        </profile>
        <profile>
            <!-- the release profile does sign, proguard, zipalign ... but does not 
                run instrumentation tests -->
            <id>release</id>
            <!-- via this activation the profile is automatically used when the release 
                is done with the maven release plugin -->
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <modules>
                <module>morse-lib</module>
                <module>morseflash-app</module>
            </modules>
            <properties>
                <!-- when i will try to enter this address the app will start :) -->
                <!-- for release i want to use my git -->
                <!-- server schema is defined globally for all profiles but can be overridden
                    here for the local profile -->
                <!-- this properties are good for all the maven modules -->
                <server_host>github.com</server_host>
                <server_path>/jayway/maven-android-plugin-samples</server_path>
            </properties>
        </profile>
    </profiles>

</project>

4.0.0
com.simpligility.android.morse
morseflash父项
1.0.0-SNAPSHOT
聚甲醛
MorseFlash-父项
http
朱尼特
朱尼特
4.8.1
com.google.android
安卓
2.3.1
com.google.android
安卓测试
2.3.1
maven jarsigner插件
1.2
maven资源插件
2.5
UTF-8
com.jayway.maven.plugins.android.generation2
安卓maven插件
3.4.1
10
23
10000
真的
真的
org.codehaus.mojo
构建助手maven插件
1.5
org.eclipse.m2e
生命周期映射
1.0.0
com.jayway.maven.plugins.android.generation2
安卓maven插件
[3.2.0,)
清单更新
标准
真的
莫尔斯图书馆
morseflash应用程序
莫尔斯闪光仪器
192.168.1.12
释放
性能释放酶
真的
莫尔斯图书馆
morseflash应用程序
github.com
/jayway/maven android插件示例
现在,应用程序项目:

<?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>com.simpligility.android.morse</groupId>
        <artifactId>morseflash-parent</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>

    <artifactId>morseflash-app</artifactId>
    <packaging>apk</packaging>
    <name>MorseFlash - App</name>

    <properties>
        <environment>development</environment>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.simpligility.android.morse</groupId>
            <artifactId>morse-library</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </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>
    </dependencies>

    <build>

    <!-- <sourceDirectory>src</sourceDirectory> -->

    <finalName>${project.artifactId}</finalName>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <!-- use the copy resources instead of resources, which adds it to 
                            the eclipse buildpath -->
                        <phase>initialize</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.basedir}/res</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/src/templates/res</directory>
                                    <targetPath>${project.basedir}/res</targetPath>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <manifest>
                        <debuggable>true</debuggable>
                    </manifest>
                </configuration>
                <executions>
                    <execution>
                        <id>manifestUpdate</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>manifest-update</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>alignApk</id>
                        <phase>package</phase>
                        <goals>
                            <goal>zipalign</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>development</id>
            <!-- using this since activeByDefault does not work well with multiple 
                profiles -->
            <activation>
                <property>
                    <name>environment</name>
                    <value>!production</value>
                </property>
            </activation>
            <properties>
                <deployment.stage>In Development</deployment.stage>
            </properties>
        </profile>
        <profile>
            <id>production</id>
            <properties>
                <deployment.stage>In Production</deployment.stage>
            </properties>
        </profile>
        <profile>
            <id>release</id>
            <!-- via this activation the profile is automatically used when the release 
                is done with the maven release plugin -->
            <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>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- the signed apk then needs to be zipaligned and we activate proguard 
                        and we run the manifest update -->
                    <plugin>
                        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                        <artifactId>android-maven-plugin</artifactId>
                        <inherited>true</inherited>
                        <configuration>
                            <sign>
                                <debug>false</debug>
                            </sign>
                            <zipalign>
                                <skip>false</skip>
                                <verbose>true</verbose>
                                <inputApk>${project.build.directory}/${project.artifactId}.apk</inputApk>
                                <outputApk>${project.build.directory}/${project.artifactId}-signed-aligned.apk
                                </outputApk>
                            </zipalign>
                            <manifest>
                                <debuggable>false</debuggable>
                                <versionCodeAutoIncrement>true</versionCodeAutoIncrement>
                            </manifest>
                            <proguard>
                                <skip>false</skip>
                            </proguard>
                        </configuration>
                        <executions>
                            <execution>
                                <id>manifestUpdate</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>manifest-update</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>alignApk</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>zipalign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/${project.artifactId}-signed-aligned.apk</file>
                                    <type>apk</type>
                                    <classifier>signed-aligned</classifier>
                                </artifact>
                                <artifact>
                                    <file>${project.build.directory}/proguard/mapping.txt</file>
                                    <type>map</type>
                                    <classifier>release</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-signed-aligned</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

4.0.0
com.simpligility.android.morse
morseflash父项
1.0.0-SNAPSHOT
morseflash应用程序
apk
MorseFlash-应用程序
发展
com.simpligility.android.morse
莫尔斯图书馆
${project.version}
朱尼特
朱尼特
测试
com.google.android
安卓
假如
com.google.android
安卓测试
假如
${project.artifactId}
org.apache.maven.plugins
maven资源插件
初始化
复制资源
${project.basedir}/res
${project.basedir}/src/templates/res
${project.basedir}/res
真的
com.jayway.maven.plugins.android.generation2
安卓maven插件
真的
真的
<plugin>
    <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    <artifactId>android-maven-plugin</artifactId>
    <version>3.4.1</version>
    <configuration>
        <sdk>
            <platform>10</platform>
        </sdk>
        <configuration>
            <source>1.7</source>
            <target>1.7</target>
        </configuration>
        <emulator>
            <avd>23</avd>
            <wait>10000</wait>
            <!--<options>-no-skin</options> -->
        </emulator>
        <zipalign>
            <verbose>true</verbose>
        </zipalign>
        <undeployBeforeDeploy>true</undeployBeforeDeploy>
    </configuration>
</plugin>