Installation

To develop Mobiliti apps, you must install the following:

Background

Mobiliti employs a web browser metaphor where the mobile app connects to a web server during startup to get configurations and schemas of the content it will display on the device.  Included in this architecture are additional application servers and/or database servers for handling content.  The installation steps outlined here will set up those servers and prepare the development environment for creating apps and corresponding server components.

Setup

Android development is done with the Eclipse IDE.  Install Eclipse and the Android SDK according to their respective installation guides onto your development machine.  Also install Java and Tomcat on your server.  When finished, create two Eclipse projects to hold your Android app and the server code.  You can create the projects by importing Mobiliti provided stub projects.

Create an Android project in Eclipse

Before creating an app, you must set up an Android project in Eclipse. Start by importing the supplied MobilitiAndroid project into Eclipse.  After it is imported, you can refactor/rename the project for your own Android project.

After the import, open up the project properties and be sure the jars shown below are selected for the build path.

Create a Server project in Eclipse

Next, create a Java project in Eclipse to contain your server programs. Start by importing the supplied MobilitiServer project into Eclipse.  After it is imported, you can refactor/rename the project for your own server project.

After the import, open up the project properties and be sure the jars shown below are selected for the build path.

Configure

Once the Eclipse projects are created, you will need to configure and modify them to support your particular application.

Update the Android project

Every Android app has an AndroidManifest.xml file that presents essential information about the application to the Android system, information the system must have before it can run any of the application’s code.  Please review the Android Developer’s Guide documentation to understand the structure and content of the manifest.  Mobiliti requires specific manifest settings to remain as provided, but the following need to be updated for your app:

  • package=”yourPackageNameSpace”
  • android:label=”Your App Name”
  • android:icon=”@drawable/yourAppIcon”
  • android:theme=”@style/yourAppTheme”
  • <meta-data android:name=”mapsKey” android:value=”yourGoogleMapsKey” /> (optional)
  • <meta-data android:name=”facebookKey” android:value=”yourFacebookKey” /> (optional)

Mobiliti is designed to use Google Maps and Facebook.  They are optional so if your app doesn’t need these services, you can remove the respective manifest entries.  See the sample manifest below with the XML areas to be changed highlighted in bold.

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android&#8221;

package=”yourPackageNameSpace

android:versionCode=”1″

android:versionName=”1.0″>

<application

android:label=”Your App Name

android:icon=”@drawable/yourAppIcon

android:theme=”@style/yourAppTheme“>

<activity android:name=”mobiliti.android.ui.Launcher” android:screenOrientation=”nosensor” >

<intent-filter>

<action android:name=”android.intent.action.MAIN” />

<category android:name=”android.intent.category.LAUNCHER” />

</intent-filter>

</activity>

<activity android:name=”mobiliti.android.ui.Info” android:screenOrientation=”nosensor” />

<activity android:name=”mobiliti.android.ui.Controller” android:screenOrientation=”nosensor” />

<activity android:name=”mobiliti.android.ui.MapAdapter” android:screenOrientation=”nosensor” />

<uses-library android:name=”com.google.android.maps” />

<meta-data android:name=”contentURL” android:value=”http://your/contentDir” />

<meta-data android:name=”mapsKey” android:value=”yourGoogleMapsKey” />

<meta-data android:name=”facebookKey” android:value=”yourFacebookKey” />

</application>

<uses-permission android:name=”android.permission.INTERNET” />

<uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION” />

<uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION” />

<supports-screens

android:largeScreens=”true”

android:normalScreens=”true”

android:smallScreens=”false”

android:anyDensity=”true” />

<uses-sdk android:minSdkVersion=”8″ android:targetSdkVersion=”8″ />

<uses-configuration android:reqTouchScreen=”finger” />

</manifest>

Note:  The framework provides built-in support for Google Maps and Facebook.  Supply your respective keys in the meta-data properties of the manifest to turn those features on.

Update the Server project

The server project contains several configuration files found in the WEB-INF directory.  The open source logging facility log4j is used for server logging.  Update the log4j.properties file as needed for your environment.

If you will be connecting the server to a relational database, you must modify the persistence.xml file.  Mobiliti uses the Java Persistence API (JPA) and Hibernate for database access and persistence.  Mobiliti is pre-configured to use the optional c3p0 connection pooling software. There are other Hibernate subcomponents you may install for your particular needs if you wish. You may alter other parameters in the persistence.xml and c3p0.properties files to fit your server’s environment.  At a minimum, change the parameters shown in bold below:

<?xml version=”1.0″ encoding=”UTF-8″?>
<persistence version=”1.0″ xmlns=”http://java.sun.com/xml/ns/persistence&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd”&gt;

<persistence-unit name=”ServiceFactory” transaction-type=”RESOURCE_LOCAL”>

<provider>org.hibernate.ejb.HibernatePersistence</provider>

<properties>

<property name=”hibernate.archive.autodetection” value=”class”/>

<property name=”hibernate.format_sql” value=”false”/>

<property name=”hibernate.show_sql” value=”false”/>

<property name=”hibernate.dialect” value=”org.hibernate.dialect.MySQLDialect” />

<property name=”hibernate.connection.driver_class” value=”com.mysql.jdbc.Driver” />

<property name=”hibernate.connection.url” value=”jdbc:mysql://databaseURL” />

<property name=”hibernate.connection.username” value=”username” />

<property name=”hibernate.connection.password” value=”password” />

<property name=”hibernate.hbm2ddl.auto” value=”update”/>

<property name=”hibernate.order_updates” value=”false”/>

<property name=”hibernate.generate_statistics” value=”false”/>

<property name=”hibernate.connection.provider_class” value=”org.hibernate.connection.C3P0ConnectionProvider” />

<property name=”hibernate.c3p0.acquire_increment” value=”3″ />

<property name=”hibernate.c3p0.min_size” value=”3″ />

<property name=”hibernate.c3p0.max_size” value=”15″ />

<property name=”hibernate.c3p0.max_statements” value=”0″ />

<property name=”hibernate.c3p0.idle_test_period” value=”300″ />

<property name=”hibernate.c3p0.timeout” value=”600″ />

</properties>

</persistence-unit>

</persistence>

Note: the web.xml file is used by Mobiliti and should not be altered!

Generate keystore

Android apps require a keystore file that is used during app generation for signing the app.  Please review the Android developer documentation here for more information.  You can create the keystore manually or use the sample Ant build.xml shown below.

Create Ant build.xml (optional)

Ant can be used to automate many tasks for building and deploying code within Eclipse.  You can use the sample below to help create a build script for your projects.

<project name=”Ant tools” default=”deploy”>

<property name=”workspace” value=”/your/workspace/path” />

<property name=”alias” value=”yourAlias” />

<property name=”keystore” value=”your.keystore” />

<property name=”password” value=”yourPassword” />

<target name=”deploy”>

<echo message=”Building the war file”/>

<war destfile=”${workspace}/yourAppDir/yourApp.war

webxml=”${workspace}/yourAppDir/WEB-INF/web.xml” update=”false”>

<zipfileset dir=”${workspace}/yourAppDir/content” prefix=”content”/>

<classes dir=”${workspace}/yourAppDir/WEB-INF/classes” />

<classes dir=”${workspace}/yourAppDir/bin” />

<lib dir=”${workspace}/yourAppsDir/lib” />

</war>

</target>

<target name=”keystore”>

<echo message=”Generating keystore”/>

<delete file=”${keystore}” quiet=”true” failonerror=”false”/>

<genkey alias=”${alias}” keyalg=”RSA” keypass=”${password}” storepass=”${password}” keystore=”${keystore}” validity=”10000″ dname=”cn=???, ou=???, o=???, c=??“/>

</target>

</project>

 


%d bloggers like this: