简体   繁体   English

将自定义android eclipse项目导出到Maven构建类型

[英]Export custom android eclipse project to maven build type

The goal was to export existing android eclipse project to maven type. 目标是将现有的android eclipse项目导出为maven类型。 To do this, it was required to download .m2 plugin . 为此,需要下载.m2 plugin Right click on project and Configure-->Convert To Maven Project , what opened the window " Create new POM " with: 右键单击项目,然后Configure-->Convert To Maven Project ,随即打开窗口“ Create new POM ”,其中:

在此处输入图片说明

The question is what should be selected in packaging type while there is only jar/pom/war . 问题是当只有jar/pom/war时,应该选择哪种包装类型。 I believe there should be " apklib " but when we type it there after pom.xml generation: 我相信应该有“ apklib ”,但是当我们在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>X.0.0</modelVersion>
  <groupId>Name</groupId>
  <artifactId>Artifact</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>apklib</packaging>
</project>

Eclipse response with : Eclipse响应:

Project build error: Unknown packaging: apklib

Regards 问候

maven has no built-in packaging "apklib", which is probably why youre getting the error. Maven没有内置包装“ apklib”,这可能就是您得到错误的原因。

you havent specified which maven plugin youre using to build android artifacts, but assumming its this one your pom needs to look like this (taken from their samples ) 您尚未指定要使用哪个Maven插件来构建android构件,但假设插件您的pom需要看起来像这样(摘自他们的示例

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.simpligility.android</groupId>
<artifactId>helloflashlight</artifactId>
<version>1.0.0</version>
<packaging>apk</packaging>
<name>HelloFlashlight</name>

<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>4.1.1.4</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <sourceDirectory>src</sourceDirectory>
    <finalName>${project.artifactId}</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <version>3.8.2</version>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>
        <plugin>
            <groupId>com.jayway.maven.plugins.android.generation2</groupId>
            <artifactId>android-maven-plugin</artifactId>
            <configuration>
                <sdk>
                    <!-- platform as api level (api level 16 = platform 4.1)-->
                    <platform>16</platform>
                </sdk>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM