Minggu, 15 Juli 2012

Set Up REAL android development environment with MAVEN integration on Eclipse

Intro

Sometime ago, i built some easy android-app to read RSS feeds and post something on a provided url. Basically, i already knew how to build an android application using eclipse. But that just a start! Real android-apps-development, involving on several libraries and it takes hours to resolve required dependencies  without a tools to work on resolving those dependencies. Either you lost on finding the dependencies required or your apps getting too big when your apps ready to use. That's why MAVEN comes in hand.

Why MAVEN ?

Maven had the technology to split your application into several libraries and adding dependencies unto those libraries. That way, you won't be confused or lost in space when trying to note down your application dependencies. That's why maven should be REALLY considered when you building a large application. Well, what i mean large is an application which is more than hello world :-D

Preparation

Downloads

  1. J2SDK (here)
  2. Eclipse WTP (here)
  3. Maven (here)
  4. Android-SDK (here)

Setting up

Installing

  1. Install / Extract Java, and set your JAVA_HOME environment
  2. Extract Eclipse
  3. Install Maven (I'm working another post for guidelines on installing maven)
  4. Install Android-SDK (I'm working another post for guidelines on installing Android-sdk)

Configure

  1. Configure Eclipse
    1. Install m2e
    2. Install m2e-android support
    3. Point maven into local installation directory
    4. Install Android  AVD and download required emulators and runtime
    5. Set's up Android default runtime
  2. Testing your maven installation

Create My First Android Project

Create New Android Application Project

Right click on project workspace -> New -> Android Application Project

  • Fill Up :
  • Application Name
  • Project Name
  • Package Name

Choose
Build SDK
Minimum Required SDK

  1. Next
  2. Next



On this screen we fill up the first activity we have on our new android application
Fill Up :
  • Activity Name
  • Layout Name
  • Click Finish

Mavenize Project

  1. Create new XML template

    1. Window -> preference -> XML -> templates
      - Click New




  • Fill up :
  • Name
  • Description
  • Copy-paste this following text to Pattern

 4.0.0

 
  org.someapp.somename
  someapp-android-somename
  theAppVersion
 

 the-app-artifact
 apk
 the-app-name

 
 

 
 

 
 






- Choose New XML within  Context
- Click OK
- Click OK
    1. On root of your project, right click and then choose New -> Other -> XML -> XML File
      Give your new XML File name : pom.xml
      Choose Template Name that you've defined earlier on step 1 (one)
    2. Modify your pom.xml file
      1. <parent> tag
         org.someapp.somename
          someapp-android-somename
          theAppVersion
        
        
        Change value on tag :

        - groupId : into application group id  (ex: org.mycompany.myapp)
        - artifactId : into application artifact id. (ex: myCompanyApp.myFirstApp)
        - version : Application Version (ex: 1.0.0)
      2. <artifactId> tag
        Change value on tag :
        - artifactId : into application artifact id. (ex: myCompanyApp.myFirstApp)
      3. <name> tag
        - name : into application name (ex: myFirstApp)
      4. <properties> tag
        add project dependencies before </properties> tag. Several required properties for this tag are :


         
        
                    com.google.android
                    android
                    ${android-version}
                    provided
                
        
        If we want to add additional library such as spring-android library : just add the following  into this tag.

        
            org.springframework.android
            spring-android-rest-template
            ${spring-android-version}
        
        
    3. You are set and done just try to run mvn clean , mvn install, mvn android:deploy


Senin, 09 Juli 2012

Introduction

First post on this blog !

Well i've decided to move my blog to blogger.com from mylifemyandroid.wordpress.com. Sadly, i haven't figured out how to import my old content into this blog.

Well, everything sets-up and Go blogging!