我有一個android項目,我使用maven來管理它,它在命令行中運行良好。如下施工:M2E沒有與存在的Maven項目一起工作
我的項目
| --android
| ---- SRC
| ---- pom.xml的
| ----......
| - 普通
| ---- SRC
| ----資產
| ----回購
| --desktop
| --pom.xml
我把共享代碼和資產放在公共目錄中。在Android的目錄pom.xml的是:
<project>
........
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.badlogic.gdx</groupId>
<artifactId>gdx</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.badlogic.gdx</groupId>
<artifactId>gdx-backend-android</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.google.ads</groupId>
<artifactId>GoogleAdMobAdsSdk</artifactId>
<version>4.0.4</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0-alpha-14</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 or api level (api level 4 = platform 1.6)-->
<platform>8</platform>
</sdk>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
<sources>
<source>../common/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>../common/assets</directory>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>libs</id>
<url>file://${basedir}/../common/repo/</url>
</repository>
</repositories>
</project>
正如你可以在上面看到,我設定集結幫手 - Maven的插件此外SRC目錄,資源目錄設置爲通用/ src目錄,我也有一個通用/回購的本地倉庫來管理我的第三個庫。
當我使用命令行時,一切都很好,我可以用手機「安裝android:deploy」。但是當我用M2E將它導入到Eclipse中時,我遇到了以下問題
我在pom.xml中添加的src目錄沒有顯示在Eclipse工作區中,因此android/src中的代碼找不到包。
如果我在Eclipse中手動鏈接源文件夾,它告訴我應該更新maven配置,並且我做了另一個錯誤「不能在'android'中嵌套'android/gen'爲了啓用嵌套, android'「顯示出來。
我完全被這混亂弄糊塗了。任何人都面臨同樣的問題,爲什麼我可以在命令行中使用maven,並且不能在M2E中,謝謝?
除了ADT和m2e,你還需要另外一個插件[m2e-android](https://github.com/rgladwell/m2e-android)來讓你的mavenized android項目在Eclipse中工作。 – yorkw
我有這個插件。我會再次重建這個項目,希望這個錯誤沒有發生。 –
@Matrix,所以我可以確認你是否使用m2e-android,或者你現在是? –