我们的团队决定在我们相当大的项目(300个班级)中使用Maven而且我是新手。到目前为止我正在编写pom.xml文件。我将所有库都写入<dependency>
,但不知道下一步该做什么。我的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>com.asd.android.asd</groupId>
<artifactId>asd</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>asd</name>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.1.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>2.0-no_aop</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>20030203.000550</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.2.5</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>org.roboguice</groupId>
<artifactId>roboguice</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-commonshttp4</artifactId>
<version>1.2.1.2</version>
</dependency>
<dependency>
<groupId>oauth.signpost</groupId>
<artifactId>signpost-core</artifactId>
<version>1.2.1.1</version>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>2.1.11</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.asd.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.1.1</version>
<extensions>true</extensions>
</plugin>
</plugins>
</pluginManagement>
</build>
对于每个班级我都会遇到这样的错误:
[ERROR] interface AccountService
/Users/asd/Documents/asd/asd-android/asd/src/com/asd/android/asd/api/ws/AccountService.java:[46,25] error: cannot find symbol
有什么问题?
答案 0 :(得分:1)
POM看起来不完整,android-archetype POM也配置了android-maven-plugin,同时指定了SDK元素和Emulator元素。看看,
如果它是你第一次做一个android项目,并且你有一个项目的大量项目,我建议你使用原型来构建一个新的mavenized项目,确保包含的“Hello world”类型项目原型运行。
然后,您很高兴在IDE和控制台中工作,然后复制主项目并重构原型以适合您的项目。
答案 1 :(得分:1)
我怀疑你在插入你的pom之后没有对你的Eclipse项目进行过少化。
右键点击项目库 - &gt;配置 - &gt;转换为Maven项目
修改强>
其他可能的原因:
1)你没有把你的srources放在
2)你的pom中有些字段缺失或不完整:
<packaging>apk</packaging>
标题中的:
<modelVersion>4.0.0</modelVersion>
<groupId>com.asd.android.asd</groupId>
<artifactId>asd</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>apk</packaging>
<name>asd</name>
构建
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<extensions>true</extensions>
<version>3.5.0</version>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6) -->
<!-- platform or api level (api level 8 = platform 2.2) -->
<!-- platform or api level (api level 16 = platform 4.1) -->
<!-- platform or api level (api level 17 = platform 4.2) -->
<platform>16</platform>
</sdk>
</configuration>
</plugin>
</plugins>