Samstag, 12. Oktober 2013

BARACUS from Scratch : Part 1 - Setting up the application

Table of Contents

In this tutorial I am going to show You how to create a simple android project using maven and how to modify the pom.xml in order get Baracus available in Your application.


DEPRECATION NOTICE : 


THIS TUTORIAL IS ONLY NEEDED WHEN YOU WANT TO USE ANOTHER ANDROID ARCHETYPE! USE THE BARACUS MAVEN ARCHETYPE TO CREATE A PLAIN BARACUS ANDROID APPLICATION! 

SIMPLY TAKE A LOOK HERE AND FOLLOW THE GUIDE


Step 1 : create an android application from scratch

Before You can start using the framework You need to setup a project. I personally prefer Maven to manage my project dependencies and build stuff. I use

mvn archetype:generate

to create a maven managed application from scratch. Just type in "android" after the list of numbers appeared and choose an android quickstart archetype. Then configure Your maven based application by setting a group Id, an artifact Id and a version. Finally, choose the platform version. Notice, You are going to need minimum version 14 to use baracus. This includes all android platforms starting from android version 4.0.1.2

Then You can alter the API-Level and the plugin version. I set the android version to 4.0.1.2.
...
<platform.version>4.0.1.2/platform.version>
...

Finally, You must define the location, where Your android SDK is stored. Therefore You must set the android.sdk.path property in Your properties. So my pom-properties now look like this :
   
<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <platform.version>3.2</platform.version>
  <android.plugin.version>3.6.0</android.plugin.version>
  <android.sdk.path>/usr/java/adt-bundle-linux-x86_64/sdk</android.sdk.path>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 </properties>

If you have downloaded the matching android sdk stuff using the sdk/tools/bin/android utility, You now should be able to build the project. If You altered the API level to 13 (Honeycomb), You must move the res/values/values-v14 away in order to make the project compileable. When You are done, You have a sample project, which You can import into Your IDE (I personally use Jetbains IntelliJ, but there is no problem to use Eclipse or Netbeans instead).

Up to here, the entire proceeding is completely independent to any framework, so lets proceed adding the framework

Step 2 : Add the maven dependency for the framework

Notice : BARACUS has moved to Maven Central. You now can use the below coordinates using minimum version <version>0.7-Beta1</version> without any additional repository settings. The framework jars then will be downloaded from central repo.

Now we add the maven dependency to the BARACUS framework to our pom.xml. Afterwards, my dependencies look like this :

<dependencies>
 <dependency>
  <groupId>com.google.android</groupId>
  <artifactId>android</artifactId>
  <version>${platform.version}</version>
  <scope>provided</scope>
 </dependency>
        <dependency>
            <groupId>org.baracus</groupId>
            <artifactId>baracus-framework</artifactId>
            <version>${baracus.version}</version>
            <type>apklib</type>
        </dependency>
</dependencies>

You need to define the ${baracus.version} in Your properties. Please refer to www.baracus.org for the latest version.

Now You are done, the framework will be available to the application You are going to build. In the next tutorial is going to show You how to setup the application context.

Next Chapter 

Defining the Application Context and making use of DI+IOC

Keine Kommentare:

Kommentar veröffentlichen