在高效創建健壯的Android應用-Maven Android 開發文中提到,Maven in Android 聽起來很牛逼,你是否是很想立刻弄個HelloWorld,可是你可能要懊惱了,由於你立刻回碰到Project build error: Unknown packaging: apk的錯誤,而後就停在這裏了,我以前也是由於碰到這個問題就停了,而後就想罵人,特別是那個引誘你嘗試的那我的(好比我),好了。這就是本文的來源。本文也會對不斷碰到的問題進行總結,你有特別的問題也可用提出來,我到時候進行總結. html
Project build error: Unknown packaging: apk, java
在Eclipse中安裝m2e-android插件 android
安裝源:http://rgladwell.github.com/m2e-android/updates/ 安裝方法:Help -> Install new Software -> 在出來的對話框中點擊 Add -> Name:m2e-android Location:http://rgladwell.github.com/m2e-android/updates/ 而後就下一步下一步了,你懂的. 也能夠經過: Preferences -> Maven -> Discovery and click "Open Catalog".而後選擇 m2e android connector 安裝好之後就能夠解決這個問題了
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later. git
在項目的pom.xml中修改你的org.apache.maven.plugins的版本號,可直接複製下面那一段更新 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin>
dependency=[com.actionbarsherlock:library:apklib:4.1.0:compile] not found in
workspace github
com.actionbarsherlock.library 換了artifactId了,是actionbarsherlock,而且使用4.4.0的版本.. macos
Plugin execution not covered by lifecycle configuration: com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.8.0:consume-
aar (execution: default-consume-aar, phase: compile) apache
可參考1參考2
好了,在你的maven配置裏,增長以下一段便可解決:
org.eclipse.m2e
lifecycle-mapping
1.0.0
com.jayway.maven.plugins.android.generation2
android-maven-plugin
3.5.0
manifest-update app
No Android SDK path could be found. eclipse
在settings.xml裏面添加(若是你連settings.xml都沒的話請點這裏) maven
<profiles> <profile> <id>android</id> <properties> <android.sdk.path> /Users/lily/android-sdk-macosx <!-- 此處爲本身sdk路徑 --> </android.sdk.path> </properties> </profile> </profiles> <activeProfiles> <!--make the profile active all the time --> <activeProfile>android</activeProfile> </activeProfiles>
@Override 的代碼所有都報錯
默認Maven中的JAVA版本是1.5,只要修改爲1.6就行了 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin>
java.lang.ClassNotFoundException: org.sonatype.aether.RepositorySystem
請看BUG issue 395 on Maven Android plugin
使用最新版本的Maven3.1.1,使用3.8的android-maven-plugin <plugin> <groupId>com.jayway.maven.plugins.android.generation2</groupId> <artifactId>android-maven-plugin</artifactId> <version>${android.plugin.version}</version> <extensions>true</extensions> <configuration> <sdk> <platform>16</platform> </sdk> </configuration> </plugin>
maven和android-maven-plugin版本不匹配,經常會出現的錯誤(就在問題裏面哦)
http://stackoverflow.com/questions/19174392/failed-to-execute-goal-com-jayway-maven-plugins-android-generation2
Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources (default-generate-sources) on project my-android-application: Execution default-generate-sources of goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources failed: A required class was missing while executing com.jayway.maven.plugins.android.generation2:android-maven-plugin:3.6.0:generate-sources: Lorg/sonatype/aether/RepositorySystem;
感受用MAVEN就是一個大坑啊,但願你看了本文以後再也不被坑.