Maven 问题总结

高效建立健壮的Android应用-Maven Android 开发文中提到,Maven in Android 听起来很牛逼,你是不是很想马上弄个HelloWorld,但是你可能要懊恼了,因为你马上回碰到Project build error: Unknown packaging: apk的错误,然后就停在这里了,我之前也是因为碰到这个问题就停了,然后就想骂人,特别是那个引诱你尝试的那个人(比如我),好了。这就是本文的来源。本文也会对不断碰到的问题进行总结,你有特别的问题也可用提出来,我到时候进行总结.

问题集合

  1. Project build error: Unknown packaging: apk,

    在Eclipse中安装m2e-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 安装好以后就可以解决这个问题了
    
  2. maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.

    在项目的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>
    
  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都没的话请点这里

    <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>
    
  6. @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>
    
  7. 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>
    
  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;

  9. 最后原文出处  http://my.oschina.net/huami/blog/175570

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值