`
hyl198611
  • 浏览: 228747 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

maven android-maven-plugin

阅读更多

以下这个问题 缠绕了 我很长时间 google 上搜了半天也没有相关的说明或者很乱!

环境:eclipse 3.6,ADT-14.0.0.zip,maven 2.0.11,maven-android-plugin 2.8.4,M2eclipse

 

pom.xml 内容如下

 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"    
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    
            xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">    
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.lekan</groupId>
    <artifactId>Activity_Test</artifactId> 
    <packaging>apk</packaging>  
    <version>0.1-SNAPSHOT</version> 
    <name>Android_Test</name>   
   
   
    <dependencies>    
      <dependency>     
         <groupId>com.google.android</groupId>   
         <artifactId>android_11</artifactId>         
         <version>${android-version}</version>       
         <scope>provided</scope>     
      </dependency>   
    </dependencies>     
                   
<build>               
<sourceDirectory>src</sourceDirectory>
<plugins>
          <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-compiler-plugin</artifactId>
              <version>2.3</version>
              <configuration>
                  <source>1.5</source>
                  <target>1.5</target>
                  <encoding>utf-8</encoding>
              </configuration>
          </plugin>
        
          <plugin>             
             <groupId>com.jayway.maven.plugins.android.generation2</groupId>    
             <artifactId>maven-android-plugin</artifactId>     
             <version>2.8.4</version>             
             <configuration>               
                 <sdk>
                     <path>${sdk.path}</path>         
                     <platform>${android-platform}</platform>  
                 </sdk>      
                <emulator>                       
                 <avd>${android-emulator}</avd>   
                </emulator>
                <deleteConflictingFiles>true</deleteConflictingFiles>
               </configuration>          
              <extensions>true</extensions>     
          </plugin>      
</plugins>
   
</build>

<properties>
    <sdk.path>c:\android_sdk</sdk.path>    
    <android-platform>11</android-platform>  
    <android-version>3.0</android-version>   
    <android-emulator>android-11</android-emulator>  
</properties>



 </project>

 

使用 mvn  package 报错

Cannot find required method com.android.sdklib.build.ApkBuilder.addNativeLibraries(java.io.File, java.lang.String)

 

Cannot find required method
java.lang.NoSuchMethodException: com.android.sdklib.build.ApkBuilder.addNativeLibraries(java.io.File, java.lang.String)
    at java.lang.Class.getMethod(Class.java:1605)
    at com.jayway.maven.plugins.android.phase09package.ApkBuilder.initialize(ApkBuilder.java:102)
    at com.jayway.maven.plugins.android.phase09package.ApkMojo.initializeAPKBuilder(ApkMojo.java:294)
    at com.jayway.maven.plugins.android.phase09package.ApkMojo.createApkFile(ApkMojo.java:162)
    at com.jayway.maven.plugins.android.phase09package.ApkMojo.execute(ApkMojo.java:144)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

 

折腾了很久终于找到关键所在 我将maven 升级到 maven 3.0.3 在将android-maven-plugin 升级到 3.0.0

设置 eclipse windows-preferences-maven-installations 添加 本地安装的maven3.0目录

修改后的pom.xml

 

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

     <modelVersion>4.0.0</modelVersion>
    <groupId>com.lekan</groupId>
    <artifactId>activity_test</artifactId> 
    <packaging>apk</packaging>  
    <version>0.1-SNAPSHOT</version> 
    <name>android_test</name>  

     <properties>
          <android-platform>7</android-platform>
          <maven-android-plugin-version>3.0.0</maven-android-plugin-version>
          <android-version>2.1</android-version>
     </properties>

     <dependencies>
          <dependency>
               <groupId>com.google.android</groupId>
               <artifactId>android_7</artifactId>
               <version>${android-version}</version>
               <scope>provided</scope>
          </dependency>
     </dependencies>

     <build>
          <sourceDirectory>src</sourceDirectory>
          <plugins>
               <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-compiler-plugin</artifactId>
                     <version>2.3.2</version>
                     <configuration>
                           <source>1.6</source>
                           <target>1.6</target>
                           <encoding>utf-8</encoding>
                           <showWarnings>true</showWarnings>
                     </configuration>
               </plugin>
               <plugin>
                     <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                     <artifactId>android-maven-plugin</artifactId>
                     <version>${maven-android-plugin-version}</version>
                     <extensions>true</extensions>
                     <configuration>
                         <sdk>
                             <path>${env.ANDROID_SDK_HOME}</path>
                             <platform>${android-platform}</platform>
                         </sdk>

                     </configuration>
               </plugin>
           </plugins>
     </build>
    
</project>
当让你也可以将签名 流程 配置到 pom里!

在解决这个问题的同时搜索到不少好的文章以下共享链接:

http://www.cnblogs.com/Pickuper/archive/2011/06/14/2078969.html

 

http://www.blogjava.net/askcuix/archive/2011/03/07/345897.html

 

http://www.cnblogs.com/feisky/archive/2011/03/13/1650076.html

 

http://code.google.com/p/maven-android-plugin/issues/detail?id=209#c0

 

http://code.google.com/p/maven-android-plugin/issues/detail?id=210

 

http://www.cnblogs.com/abob/archive/2010/06/24/1764521.html

 

最后有什么不明白的 可以留言!

分享到:
评论
4 楼 hyl198611 2013-03-27  
sunshine2176 写道
您好,android-maven-plugin的下载地址是什么,在google上找半天也没找到下载地址
http://code.google.com/p/maven-android-plugin/wiki/Source?tm=4  这个网址 我一搜索就搜索到了! 不知道你如何使用的搜索条件!
3 楼 sunshine2176 2012-08-14  
您好,android-maven-plugin的下载地址是什么,在google上找半天也没找到下载地址
2 楼 hyl198611 2012-04-13  
韩三小刀 写道
您好,我用eclipse更新android-maven-plugin总更新不下来,不知道是否是网络问题。 您可以将已安装此插件的eclipse发给我么? 我的邮箱595656878@qq.com

建议你最好不用去用eclipse 去更新 自己下载 本地安装!
1 楼 韩三小刀 2012-04-09  
您好,我用eclipse更新android-maven-plugin总更新不下来,不知道是否是网络问题。 您可以将已安装此插件的eclipse发给我么? 我的邮箱595656878@qq.com

相关推荐

Global site tag (gtag.js) - Google Analytics