Show TOC

Setting Up Eclipse with ADT for Native SDK DevelopmentLocate this document in the navigation structure

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 Start of the navigation path File Next navigation step New Next navigation step Project End of the navigation path.
  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>\MobileSDK<version>\NativeSDK\ODataFramework\Android\ to a <Parent directory> in your host development system.
    Download the required libraries. The following is the minimum requirement. Other libraries may be required, depending on the develoment scenario, for example, for different logon scenarios:
    • Supportability
      • ClientLog-<version>.jar
      • E2ETrace-<version>.jar
      • SupportabilityFacade-<version>.jar
    • OData
      • HttpConvAuthFlows-<version>.jar
      • HttpConversation-<version>.jar
      • ODataAPI-<version>.jar
      • ODataOnline-<version>.jar
      • XscriptParser-<version>.jar
      • odataoffline.jar
    Note <version> represents the version of the jar file, for example 3.5.0.
  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).
  5. Click OK, then click the directory name (not the checkbox) in the left pane and select the relevant JAR in the right pane from <SMP_HOME>\MobileSDK3\NativeSDK\ODataFramework\Android\libraries and click Finish. This step physically places the library into your project. Select one.
  6. Right-click your project, choose Build Path > Configure Build Path, click the Libraries tab, then click Add JARs.
  7. 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 libraries/assets folder path within the SDK zip file into your application assets folder without unarchiving the content.
  9. (Optional) Link the Javadocs for a given library into your project:
    Go to Start of the navigation path Java Build Path Next navigation step Libraries End of the navigation path, open the library of interest and click and edit it’s Javadoc entry to attach external documentation to the project. For this to work the API documentation JAR must be selected. Make sure to properly select the path within the archive that points to the folder containing index.html in the zip.
    Note On certain Eclipse and ADT version combinations this does not work, in which case you can unzip the documentation to a folder and then browse to the Javadocs using any Web browser.
  10. Build the application.