maven support for android projects?

前端 未结 5 1149
面向向阳花
面向向阳花 2021-01-01 15:02

I want to start a project for Android but i really like to build it using Maven. Does Google provide support for Maven or plan to support it? It would be great if anybody kn

5条回答
  •  感动是毒
    2021-01-01 15:41

    as @Riduidel said before, you can use com.jayway.maven.plugins.android.generation2 plugin.
    Note, that you don't need download any plugins, you need to have just the maven for using this plugin.
    How I did it:

    1. manually add pom.xml to your android project (to the root of project).

    2. download apache-maven-3.1.1 and add your bin folder ( ex D:\java\apache-maven-3.1.1\bin;) to path in Environment Variables.

    3. configure settings.xml in [Your_maven_path]\conf with next:

        
      
           com.jayway.maven.plugins.android.generation2
      
       
      
    4. Add content to pom.xml. My example:

          
          
              4.0.0
              com.example.ENumbers
              ENumbers
              1.0
              apk
              MainApp
      
              
                  2.2.1
              
      
              
                  
                      com.google.android
                      android
                      ${platform.version}
                      provided
                  
                  
                      org.simpleframework
                      simple-xml
                      2.7.1
                      provided
                  
                      
                          xpp3
                          xpp3
                      
                      
                          stax-api
                          stax
                      
                      
                          stax
                          stax
                      
                      
                          spring-web
                          org.springframework
                      
                      
                          commons-logging
                          commons-logging
                      
                     
                  
              
      
              
                  src
                  
                      
                          com.jayway.maven.plugins.android.generation2
                          android-maven-plugin
                          3.8.1
                          
                              ${project.basedir}/AndroidManifest.xml
                              ${project.basedir}/assets
                              ${project.basedir}/res
                              ${project.basedir}/src/main/native
                              
                                  
                                      D:\Program Files\Android\android-sdk
                                  
                                  22
                              
                              true
                          
                          true
                      
      
                      
                          maven-compiler-plugin
                          2.3.2
                          
                              1.6
                              1.6
                          
                      
                  
              
          
      

    Look at important , nodes, it's content and com.google.android dependency.

    1. Now you can open Maven window in your IDE. For Intellij Idea I do it next:
      Edit->Tool Windows->Maven and add your pom.xml for initializing maven directory.
    2. That's all.

提交回复
热议问题