android – 使用maven构建时,APK缺少一些类

android – 使用maven构建时,APK缺少一些类,第1张

概述这是 this question的副本,但答案并没有解决我的问题. 我特定构建环境的一些背景知识: 我正在使用Android maven plugin和this示例项目.该项目由父pom.xml组成,然后是三个子模块(项目)中每个子模块的pom.xml.每个子模块将父级定义为父级. 当我在原始下载的项目上运行mvn clean install时,它会在手机上构建和安装/运行. 但我没有将源添加到E 这是 this question的副本,但答案并没有解决我的问题.

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

我正在使用Android maven plugin和this示例项目.该项目由父pom.xml组成,然后是三个子模块(项目)中每个子模块的pom.xml.每个子模块将父级定义为父级.

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

但我没有将源添加到Eclipse中,它运行良好,使mvn构建脚本不再起作用(即apk较小且缺少类).

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

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

更新对于遇到类似问题的人,我已经开始在位于here的Google Group [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>

现在为app项目:

<?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>
解决方法 所以事实证明,在Eclipse中手动设置项目时,我只是打乱了项目结构.一位同事提到了mvn eclipse:eclipse命令,这是偶然的机会,它解决了我所有的问题.

参考this样本项目.我做了以下工作,以便在Eclipse和Maven中完成所有工作.

> cd进入每个项目{morse-lib,morseflash-app,morseflash-instrumentation}并运行mvn eclipse:eclipse.
>在Eclipse中单独导入每个项目.
不是* -app和* -instrumentation是AndroID项目而* -lib是一个
Java项目.所有项目都应设置为Java编译器1.6.
>对于Eclipse中的每个项目,右键单击 – >配置 – >转换为Maven
>对于项目{* -app,* -instrumentation},target / generated-sources / r – >右键单击 – >属性 – >资源 – >资源过滤器 – >添加组 – > {排除所有,文件和文件夹,所有子项(递归)}
>清理所有项目然后构建所有项目
>您现在应该能够将morseflash-app项目作为AndroID应用程序运行.
>从morseflash文件夹中的命令行(包含* -lib,* -app,* -instrumentation),你应该能够执行mvn clean install androID:deploy来获取手机上的应用程序.

希望这有助于其他人.如果没有,请给我.

总结

以上是内存溢出为你收集整理的android – 使用maven构建时,APK缺少一些类全部内容,希望文章能够帮你解决android – 使用maven构建时,APK缺少一些类所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1126812.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存