应用程序可以使用maven构建,但不能作为Android应用程序构建

时间:2014-07-22 12:02:40

标签: android eclipse maven m2e

我有一个Android项目,我使用M2E-Maven Integration for Eclipse来配置&(转换为Maven项目)。 该项目使用谷歌播放服务库,该库已转换为apklib。我将这个依赖项添加到我的项目(到我的pom.xml)。我必须提到pom是自动构建的,但是我将其替换为:

生成的那个
mvn help:effective-pom

之后我做了一个干净的安装并用maven构建了项目,在运行配置中有以下目标:

clean install -Dandroid.sdk.path="path to my sdk" android:deploy android:run

一切正常,但我的项目中有错误(所以我无法将其作为Android应用程序运行)。看起来与谷歌图书馆相关的所有内容都无法识别。 我的pom.xml看起来像这样:

<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyProject</groupId>
<artifactId>MyProject</artifactId>
<version>1.1-SNAPSHOT</version>
<name>MyProject</name>
<!-- <packaging>apk</packaging> --> <!-- if i try to add packaging it will give an error --> 
<dependencies>
    <dependency>
        <groupId>com.google.air</groupId>
        <artifactId>googleplayair</artifactId>
        <version>1.1</version>
        <type>apklib</type>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.crashlytics</groupId>
        <artifactId>crashlytics</artifactId>
        <version>1.0</version>
    </dependency>
</dependencies>
<repositories>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>Central Repository</name>
        <url>http://repo.maven.apache.org/maven2</url>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <releases>
            <updatePolicy>never</updatePolicy>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>central</id>
        <name>Central Repository</name>
        <url>http://repo.maven.apache.org/maven2</url>
    </pluginRepository>
</pluginRepositories>
<build>
    <sourceDirectory>/User/Documents/eclipse/cruzcampo-android/app/cruzcampo/src/main/java</sourceDirectory>
    <scriptSourceDirectory>/User/Documents/eclipse/MyProject/src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>/User/Documents/eclipse/MyProject/src/test/java</testSourceDirectory>
    <outputDirectory>/User/Documents/eclipse/MyProject/target/classes</outputDirectory>
    <testOutputDirectory>/User/Documents/eclipse/MyProject/target/test-classes</testOutputDirectory>
    <resources>
        <resource>
            <directory>/User/Documents/eclipse/MyProject/src/main/resources</directory>
        </resource>
    </resources>
    <testResources>
        <testResource>
            <directory>/User/Documents/eclipse/MyProject/src/test/resources</directory>
        </testResource>
    </testResources>
    <directory>/User/Documents/eclipse/MyProject/target</directory>
    <finalName>MyProject-1.1-SNAPSHOT</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.3</version>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-5</version>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
            </plugin>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.3.2</version>
            </plugin>
            <!-- </plugins> -->
            <!-- </pluginManagement> -->
            <!-- <plugins> -->
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <id>default-clean</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>default-install</id>
                        <phase>install</phase>
                        <goals>
                            <goal>install</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>default-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-testResources</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testResources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <executions>
                    <execution>
                        <id>default-testCompile</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>default-compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>default-jar</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.3</version>
                <executions>
                    <execution>
                        <id>default-site</id>
                        <phase>site</phase>
                        <goals>
                            <goal>site</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>/User/Documents/eclipse/MyProject/target/site</outputDirectory>
                            <reportPlugins>
                                <reportPlugin>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-project-info-reports-plugin</artifactId>
                                </reportPlugin>
                            </reportPlugins>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-deploy</id>
                        <phase>site-deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>/User/Documents/eclipse/MyProject/target/site</outputDirectory>
                            <reportPlugins>
                                <reportPlugin>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-project-info-reports-plugin</artifactId>
                                </reportPlugin>
                            </reportPlugins>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <outputDirectory>/User/Documents/eclipse/MyProject/target/site</outputDirectory>
                    <reportPlugins>
                        <reportPlugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-project-info-reports-plugin</artifactId>
                        </reportPlugin>
                    </reportPlugins>
                </configuration>
            </plugin>

            <plugin>
                <groupId>
                    com.jayway.maven.plugins.android.generation2
                </groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.8.2</version>
                <configuration>
                    <sdk>
                        <platform>19</platform>
                    </sdk>
                </configuration>

                <extensions>true</extensions>
            </plugin>

        </plugins>

    </pluginManagement>

</build>
<reporting>
    <outputDirectory>/User/Documents/eclipse/MyProject/target/site</outputDirectory>
</reporting>

我想现在Maven工作正常,但Android存在问题。 有什么建议吗?

1 个答案:

答案 0 :(得分:0)

Eclipse ADT不支持apklib依赖项的Maven归档格式。为了在Eclipse中成功编译,您需要拥有“Mavenised”的完整源代码(即包含一个POM,其中Maven坐标与应用程序POM中声明的依赖关系相匹配)Android库项目导入Eclipse工作区。