Maven开发Android的常见问题

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

问题集合

  1. 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 安装好之后就能够解决这个问题了
  2. 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>
  3. dependency=[com.actionbarsherlock:library:apklib:4.1.0:compile] not found in 
    workspace github

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

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

  5. 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>
  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;

最后

感受用MAVEN就是一个大坑啊,但愿你看了本文以后再也不被坑.
相关文章
相关标签/搜索