Monday, 20 August 2012

Example Step2: Install Mobile Sync & complete first sync

Note: I have shared screen shots of these steps in a zip file at the bottom of this blog. File names of the screen shot are in parentheses in the discussion below

Step 1: Install Oracle Mobile Development Kit

Launch Oracle Installer and choose to install Mobile Development Kit. I believe Oracle does not support this installation on the same machine as the Mobile Server. I installed Oracle Mobile Development Kit on Windows XP in a VM using default options.

Step 2: Install Eclipse, Android SDK
Step 3: Build Mobile Sync application
  • Launch Eclipse
  • Import simple_sync_android application (File-> Import)
  • Choose the option Import Existing Projects into Workspace
  • Ensure that MOBILE_SYNC_ANDROID_LIB is configured properly (Project Properties -> Java Build Path). In my case, I set it to C:/OraHome_1/Mobile/Sdk/android/lib/osync_android.jar
  • Create an Android Virtual Device (Window->AVD Manager)
  • Set default Build Target to Android 2.3.3 (Project Properties, choose Android and check the default target)
  • Build and run the application in the Android Emulator (Run-> Run As)
  • You should see the Mobile Sync application in your Android Emulator. If you get a ClassNotFoundException, or Force Close, see below  
 Step 4: Install Mobile Sync application on device
  •  If you were able to build the Mobile Sync application successfully and it shows up in the Emulator, then attach your Android device to the PC with USB port. 
  • Ensure that USB driver is installed 
  • Install the application onto device Run As-> with the device connected. You should see the Mobile Sync application on the device (Sync1.png)

    Caution: Do not log in to Mobile Server as yet
  • Launch Mobile Sync application and configure the setting DATA_DIRECTORY. Click the Menu button to see options to Edit OSE.INI, View Error log etc.(Sync2.png)
  • Edit the OSE.INI file. You should see no entries in OSE.INI as yet (Sync3.png)

    Add an entry similar to: SQLITE.DATA_DIRECTORY=/sdcard/net.adkoli.dbtest
    and click Save.



    In the entry above, /sdcard is the directory for external storage (also called SD card). The rest of the entry "net.adkoli.dbtest" matches the name of my mobile application created in Titanium. More on this later. 
  • Now enter User credentials and Server URL. In my example, I had created a user AA (Sync4.png)
  • Click Sync. After a few seconds, you should see message "Sync finished successfully" (Sync5.png)
Note: Detailed instructions are available in a file named "Creating Sync Application for Android" in the \mobile\sdk\samples\sync\android\simple_sync_android folder from the installation completed in Step 1 above. 

Step 5: Sanity Check
  • Use adb to check if the directory structures expected are created. You should see a directory with username appended to it. So, in my example, you would see a directory such as /sdcard/net.adkoli.dbtest/AA.

My Experience

I had a difficult time building the simple_sync_android project out of the box. I kept getting an application Force Close and ClassNotFoundException. I had to do the following to workaround this:
  1. In Eclipse, go to Project Properties
  2. Choose Java Build Path
  3. Click Order and Export tab
  4. Move "MOBILE_SYNC_ANDROID_LIB" entry Up until it is just below the /simple/sync_android/src entry
  5. Now rebuild and this worked for me
Other errors I saw were "HTTP Transport error" while I was trying to Sync. This is because my device had lost network (Sync6.png)

I also was not able to get Mobile Sync to Save the password when I chose the option to do so (checkbox Save Password). The password is somehow saved incorrectly and I kept getting "USER_INVALID" error (Sync7.png). I suspect that the Sync client is encrypting the password provided and then using the mangled version of the password without decrypting again.

Screen Shots

I have made available screenshots to help you follow this blog. Please download zip file and extract it. The names of the files referenced are in parentheses.

5 comments:

  1. i would say you did a greate job thanks; but i would say about the order tab that the real reason was the checkbox :) on it was checked when ordering

    ReplyDelete
  2. Thanks a lot!

    The screenshots links are broken.

    Could you update or send me? They will help.

    Thanks

    ReplyDelete
    Replies
    1. My apologies for the long delay. I have been traveling. I will provide these screen shots over the next day or two.

      Delete
  3. Hi Double,

    Have you developed any ADF mobile application using Sync feature.If yes Please tel me some quick steps or any sample with you please share me.

    Regards
    Siva

    ReplyDelete
  4. Hi Siva ,
    This sync app works for Application which has publications and publications items created by Mobile Database workbench or by java code . From my understanding ADF and explained sync app works differently . More about ADF in http://docs.oracle.com/cd/E18941_01/tutorials/buildmobileappscontent/adfmobiletutorial_1.html

    ReplyDelete