Maven开发Android的常见问题

问题集合

  1. Project build error: Unknown packaging: apk,

    在Eclipse中安装m2e-android插件

    01 安装源:http://rgladwell.github.com/m2e-android/updates/
    02  
    03 安装方法:Help -> Install new Software -> 在出来的对话框中点击 Add ->
    04  
    05 Name:m2e-android
    06 Location:http://rgladwell.github.com/m2e-android/updates/
    07  
    08 然后就下一步下一步了,你懂的.
    09  
    10 也可以通过:
    11 Preferences -> Maven -> Discovery and click "Open Catalog".然后选择 m2e     android connector 安装好以后就可以解决这个问题了
  2. maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.

    01 在项目的pom.xml中修改你的org.apache.maven.plugins的版本号,可直接复制下面那一段更新
    02  
    03 <plugin>
    04     <groupId>org.apache.maven.plugins</groupId>
    05     <artifactId>maven-resources-plugin</artifactId>
    06     <version>2.5</version>
    07     <configuration>
    08         <encoding>${project.build.sourceEncoding}</encoding>
    09     </configuration>
    10 </plugin>
  3. dependency=[com.actionbarsherlock:library:apklib:4.1.0:compile] not found in
    workspace

    com.actionbarsherlock.library 换了artifactId了,是actionbarsherlock,并且使用4.4.0的版本..

  4. 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)

    可参考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

  5. No Android SDK path could be found.

    在settings.xml里面添加(如果你连settings.xml都没的话请点这里

    01 <profiles>
    02     <profile>
    03         <id>android</id>
    04         <properties>
    05             <android.sdk.path>
    06                 /Users/lily/android-sdk-macosx <!-- 此处为自己sdk路径 -->
    07             </android.sdk.path>
    08         </properties>
    09     </profile>
    10 </profiles>
    11 <activeProfiles> <!--make the profile active all the time -->
    12           <activeProfile>android</activeProfile>
    13 </activeProfiles>
  6. @Override 的代码全部都报错

    01 默认Maven中的JAVA版本是1.5,只要修改成1.6就好了
    02  
    03 <plugin>
    04   <groupId>org.apache.maven.plugins</groupId>
    05   <artifactId>maven-compiler-plugin</artifactId>
    06   <version>2.1</version>
    07   <configuration>
    08     <source>1.6</source>
    09     <target>1.6</target>
    10   </configuration>
    11 </plugin>
  7. java.lang.ClassNotFoundException: org.sonatype.aether.RepositorySystem

    请看BUG issue 395 on Maven Android plugin

    01 使用最新版本的Maven3.1.1,使用3.8的android-maven-plugin
    02 <plugin>
    03     <groupId>com.jayway.maven.plugins.android.generation2</groupId>
    04     <artifactId>android-maven-plugin</artifactId>
    05     <version>${android.plugin.version}</version>
    06     <extensions>true</extensions>
    07     <configuration>
    08         <sdk>
    09             <platform>16</platform>
    10         </sdk>
    11     </configuration>
    12 </plugin>
  8. 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;

最后

1 感觉用MAVEN就是一个大坑啊,希望你看了本文之后不再被坑.

猜你喜欢

转载自qian0021514578.iteye.com/blog/2024598