gpt4 book ai didi

java - 将自定义 Android Eclipse 项目导出为 Maven 构建类型

转载 作者:行者123 更新时间:2023-12-01 12:29:29 25 4
gpt4 key购买 nike

目标是将现有的 android eclipse 项目导出为 maven 类型。为此,需要下载 .m2 插件。右键单击项目并Configure-->Convert To Maven Project,打开窗口“Create new POM”:

enter image description here

问题是,在只有 jar/pom/war 的情况下,打包类型应该选择什么。我相信应该有“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 响应:

Project build error: Unknown packaging: apklib

问候

最佳答案

maven 没有内置打包“apklib”,这可能就是您收到错误的原因。

您尚未指定您使用哪个 Maven 插件来构建 Android Artifact ,但假设其 this one你的 pom 需要看起来像这样(取自他们的 samples )

<?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>

关于java - 将自定义 Android Eclipse 项目导出为 Maven 构建类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26054397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com