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 内容如下

 


            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">    
    4.0.0
    com.lekan
    Activity_Test 
    apk  
    0.1-SNAPSHOT 
    Android_Test   
   
   
        
           
         com.google.android   
         android_11         
         ${android-version}       
         provided     
     
   
   
     
                   
               
src

         
              org.apache.maven.plugins
              maven-compiler-plugin
              2.3
             
                  1.5
                  1.5
                  utf-8
             

         

        
                       
             com.jayway.maven.plugins.android.generation2    
             maven-android-plugin     
             2.8.4             
                            
                
                     ${sdk.path}         
                     ${android-platform}  
                 
      
                                       
                 ${android-emulator}   
               

                true
              
          
              true     
         
      

   



    c:\android_sdk    
    11  
    3.0   
    android-11  




 

 

使用 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

 

      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

     4.0.0
    com.lekan
    activity_test 
    apk  
    0.1-SNAPSHOT 
    android_test  

    
          7
          3.0.0
          2.1
    


    
         
               com.google.android
               android_7
               ${android-version}
               provided
         

    


    
          src
         
              
                     org.apache.maven.plugins
                     maven-compiler-plugin
                     2.3.2
                    
                           1.6
                           1.6
                           utf-8
                           true
                    

              

              
                     com.jayway.maven.plugins.android.generation2
                     android-maven-plugin
                     ${maven-android-plugin-version}
                     true
                    
                        
                             ${env.ANDROID_SDK_HOME}
                             ${android-platform}
                        


                    

              

          

    

    

当让你也可以将签名 流程 配置到 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

 

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

你可能感兴趣的:(maven)