Creating a Project and Importing the OData Libraries

Create a new Android project in the eclipse workspace. Add library resources to the project and set other application properties.

Creating an Android Project

  1. Start the Eclipse workspace.
  2. Select File > New > Project.
  3. Select Android > Android Application Project, then Next.
  4. In the Creates a new Android Application page of the New Android Application wizard, enter the appropriate values.
  5. Click Next.
  6. In the Configure Launcher Icon window, accept the default settings and click Next.
  7. In the Create Activity window, select Create Activity, then select BlankActivity, and click Next.
  8. In the New Blank Activity window, use the appropriate values and click Finish.

Setting Up the Android SDK Library in the Plug in

Set up the Android SDK in the ADT Plugin.

  1. In the Eclipse environment, from the Window menu, select Preferences.
  2. In the left navigation pane, select the Android node.
  3. Click Browse to search for the location where you have stored the Android SDK.
  4. Click Apply and OK.

Adding User Permissions in Android Manifest File

  1. In the Eclipse project, open the Android manifest file.
  2. Add the user permissions in the AndroidManifest.xml file.

    To use the applications offline, AndroidManifest.xml should have permission for accessing network state along with registered broadcast receiver.

    :
    <! -- adding Permission to access network state --> 
        <uses-permission android:name="android.permission.INTERNET"></uses-permission>
        <! -- adding Permission to access network state -->
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" ></uses-permission>
    
    (Optional) For Offline-Capability
    <application
            .
            .
            .
            .
    >
            <receiver android:name="com.sap.mobile.lib.request.NetworkStateListener"
                      android:label="NetworkStateListener">
                      <intent-filter>
                          <action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
                      </intent-filter>
            </receiver>
      <activity
       .....
      </activity>
      .
      .
      .
    </application>
    

Importing Libraries to your Android Application Project

  1. Download the OData SDK library files from <SMP_HOME>\MobileSDK3\NativeSDK\ODataFramework\Android\ to a <Parent directory> in your host development system.
    (Online capability), Download the following libraries:
    • CoreServices
    • Connectivity
    • Common
    • DataVaultLib
    • gson
    • Parser
    • perflib
    • Request
    • Sap-e2etrace
    (To use Applications offline) Download the following libraries along with the above mentioned libraries:
    • Cache
    • Persistence
    • sqlcipher-android-2.1.1
    • commons-codec-1.3
    • guava-r09
    • libs/armeabi (includes libdatabase_sqlcipher.so, libsqlcipher_android.so and libstlport_shared.so)
    • icudt46l.zip file from assets folder
    Note: Since the X86 SQL Cipher 2.1.1 libraries are not packaged with OData SDK, SAP recommends you download and use these libraries from: https://s3.amazonaws.com/sqlcipher/SQLCipher%20for%20Android%202.1.1.zip. Copy x86 folder into libs folder, to ensure offline cache works seamlessly on Intel Atom x86 emulator.
  2. (Optional) If you did not use the project wizard to create your project, create a new folder, named libs, in your Eclipse/Android project.
  3. Right-click the libs folder and choose Import > General > File System, then click Next.
  4. Browse the file system to find the library's parent directory (where you have downloaded it).
    Note: If you use AfariaSLL.jar to provision configuration data and certificates for your SAP Mobile Platform client application, ensure to remove libcrypto.jar and libssl.jar, as AfariaSLL internally has these two libraries.
  5. (Optional) Click OK, then click the directory name (not the checkbox) in the left pane and select the relevant JAR in the right pane from AndroidoDataSDK-3.0.0-CIAT-SNAPSHOT-bin[1].zip\Android\libraries. This step physically places the library into your project.
  6. (Optional) Right-click your project, choose Build Path > Configure Build Path, click the Libraries tab, then click Add JARs.
  7. (Optional) Navigate to the JAR in the libs directory and add it. (This step converts JAR for use on Android.)

    This procedure includes a Dalvik-converted JAR in your Android project and makes Java definitions available to Eclipse in order to find the third-party classes when compiling your project's source code.

  8. Add the files from assets folder into your application assets folder.
  9. Build the application.