function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aurélien LavalAurélien Laval 

Offline Hybrid Development with CloudTunes application doesn't store offline

Hello, I am developping the CloudTunes hybrid applicationon for Android to test the offline datas and I've a problem with the data stockage.

 

When I try to store offline, I've this message : Class not found

 

I guess is not normal but I don't understand why?

 

The  error is in this function :

[code]

function regOfflineSoups() {

   if (hasSmartstore()) {
      var smartStore = cordova.require("salesforce/plugin/smartstore");
      alert("Registering soups");
      console.log("Registering soups");

      //Registering soup 1 for storing albums
      var indexesAlbums = [
         {path:"Name",type:"string"},
         {path:"Id",type:"string"}
      ];

      smartStore.registerSoup(ALBUMS_SOUP_NAME, indexesAlbums, onSuccessRegSoup, onErrorRegSoup);

      //Registering soup 2 for storing tracks
      var indexesTracks = [
         {path:"Name",type:"string"},
         {path:"Id",type:"string"},
         {path:"Album__c",type:"string"},
         {path:"Price__c",type:"string"}
      ];
      smartStore.registerSoup(TRACKS_SOUP_NAME,
      indexesTracks,
      onSuccessRegSoup,
      onErrorRegSoup);
   }
}

[/code]

 

I don't have the alert "Registering soups";

 

The error is the variabble smartStore doesn't has the file "salesforce/plugin/smartstore"?

Where sould be this file?

 

In my assets files in Eclipse? i've :

- bootconfig.js

- bootstrap.html

- cordova-2.3.0.js

- SalesforceOAuthPlugin.js

- SFHybridApp.js

- folder jquery

 

In Salesforce :

[code]

<apex:includeScriptvalue="{!URLFOR($Resource.cloudtunes_offline)}"/>

 

<apex:variablevar="cdvUrl"value="{!cordovaUrl}"/>

<apex:includeScriptvalue="{!URLFOR($Resource.Cordova, cdvUrl)}"/>

<apex:includeScriptvalue="{!URLFOR($Resource.SFHybridAppJs)}"/>

<apex:includeScriptvalue="{!URLFOR($Resource.SFSmartStorePlugin)}"/>

<apex:includeScriptvalue="{!URLFOR($Resource.cloudtunes_smartstore)}"/>

[/code]

 

Thanks for your answers.

Gaurav KheterpalGaurav Kheterpal

What version of the mobile SDK are you using? 1.5?

 

Is this the code you are looking at?

 

https://github.com/forcedotcom/SalesforceMobileSDK-Android/tree/master/native/SampleApps/CloudTunes

 

 

Aurélien LavalAurélien Laval

I'm using the version [url=https://github.com/forcedotcom/SalesforceMobileSDK-Android]1.5[/url] of the mobile SDK, I've downloaded the SDK mobile this morning to reset.

 

However, I'm looking the [url=http://salesforceresources.com/tip_sheets/for_developers/Mobile_SDK_Workbook.pdf]Mobile SDK Workbook[/url] at the tutorial 6 : Creating an Android Hybrid App.

 

I'm looking the [url=http://www.salesforce.com/docs/en/mobile_sdk/mobile_sdk.pdf]Mobile SDK Developpment Guide[/url] too and in the chapter 8 : Securely Storing Data Offline, it says I must to change the import and the extends in my class projectApp.name (Part "Adding SmartStore to Android Apps").

 

When I do this and I run my application, I get this error at the beginning :

[code]

06-24 15:14:07.072: E/Database(1010): Error copying icu data file
06-24 15:14:07.072: E/Database(1010): java.io.FileNotFoundException: icudt46l.zip
06-24 15:14:07.072: E/Database(1010): at android.content.res.AssetManager.openAsset(Native Method)
06-24 15:14:07.072: E/Database(1010): at android.content.res.AssetManager.open(AssetManager.java:313)
06-24 15:14:07.072: E/Database(1010): at android.content.res.AssetManager.open(AssetManager.java:287)
06-24 15:14:07.072: E/Database(1010): at net.sqlcipher.database.SQLiteDatabase.loadICUData(SQLiteDatabase.java:117)
06-24 15:14:07.072: E/Database(1010): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:150)
06-24 15:14:07.072: E/Database(1010): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:136)
06-24 15:14:07.072: E/Database(1010): at com.salesforce.androidsdk.store.DBOpenHelper.<init>(DBOpenHelper.java:53)
06-24 15:14:07.072: E/Database(1010): at com.salesforce.androidsdk.store.DBOpenHelper.getOpenHelper(DBOpenHelper.java:46)
06-24 15:14:07.072: E/Database(1010): at com.salesforce.androidsdk.app.ForceAppWithSmartStore.getSmartStore(ForceAppWithSmartStore.java:79)
06-24 15:14:07.072: E/Database(1010): at com.salesforce.androidsdk.phonegap.SmartStorePlugin.getSmartStore(SmartStorePlugin.java:365)
06-24 15:14:07.072: E/Database(1010): at com.salesforce.androidsdk.phonegap.SmartStorePlugin.removeSoup(SmartStorePlugin.java:358)
06-24 15:14:07.072: E/Database(1010): at com.salesforce.androidsdk.phonegap.SmartStorePlugin.execute(SmartStorePlugin.java:108)
06-24 15:14:07.072: E/Database(1010): at com.salesforce.androidsdk.phonegap.ForcePlugin.execute(ForcePlugin.java:78)
06-24 15:14:07.072: E/Database(1010): at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:61)
06-24 15:14:07.072: E/Database(1010): at org.apache.cordova.api.PluginManager.exec(PluginManager.java:224)
06-24 15:14:07.072: E/Database(1010): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:45)
06-24 15:14:07.072: E/Database(1010): at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:213)
06-24 15:14:07.072: E/Database(1010): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:566)
06-24 15:14:07.072: E/Database(1010): at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 15:14:07.072: E/Database(1010): at android.os.Looper.loop(Looper.java:123)
06-24 15:14:07.072: E/Database(1010): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-24 15:14:07.072: E/Database(1010): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 15:14:07.072: E/Database(1010): at java.lang.reflect.Method.invoke(Method.java:521)
06-24 15:14:07.072: E/Database(1010): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-24 15:14:07.072: E/Database(1010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-24 15:14:07.072: E/Database(1010): at dalvik.system.NativeStart.main(Native Method)
06-24 15:14:07.072: I/DBOpenHelper:DBOpenHelper(1010): smartstore.db/1
06-24 15:14:07.092: D/AndroidRuntime(1010): Shutting down VM
06-24 15:14:07.092: W/dalvikvm(1010): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
06-24 15:14:07.102: E/AndroidRuntime(1010): FATAL EXCEPTION: main
06-24 15:14:07.102: E/AndroidRuntime(1010): net.sqlcipher.database.SQLiteException: not an error
06-24 15:14:07.102: E/AndroidRuntime(1010): at net.sqlcipher.database.SQLiteDatabase.dbopen(Native Method)
06-24 15:14:07.102: E/AndroidRuntime(1010): at net.sqlcipher.database.SQLiteDatabase.<init>(SQLiteDatabase.java:1950)
06-24 15:14:07.102: E/AndroidRuntime(1010): at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:900)
06-24 15:14:07.102: E/AndroidRuntime(1010): at net.sqlcipher.database.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:943)
06-24 15:14:07.102: E/AndroidRuntime(1010): at net.sqlcipher.database.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:107)
06-24 15:14:07.102: E/AndroidRuntime(1010): at com.salesforce.androidsdk.app.ForceAppWithSmartStore.getSmartStore(ForceAppWithSmartStore.java:79)
06-24 15:14:07.102: E/AndroidRuntime(1010): at com.salesforce.androidsdk.phonegap.SmartStorePlugin.getSmartStore(SmartStorePlugin.java:365)
06-24 15:14:07.102: E/AndroidRuntime(1010): at com.salesforce.androidsdk.phonegap.SmartStorePlugin.removeSoup(SmartStorePlugin.java:358)
06-24 15:14:07.102: E/AndroidRuntime(1010): at com.salesforce.androidsdk.phonegap.SmartStorePlugin.execute(SmartStorePlugin.java:108)
06-24 15:14:07.102: E/AndroidRuntime(1010): at com.salesforce.androidsdk.phonegap.ForcePlugin.execute(ForcePlugin.java:78)
06-24 15:14:07.102: E/AndroidRuntime(1010): at org.apache.cordova.api.CordovaPlugin.execute(CordovaPlugin.java:61)
06-24 15:14:07.102: E/AndroidRuntime(1010): at org.apache.cordova.api.PluginManager.exec(PluginManager.java:224)
06-24 15:14:07.102: E/AndroidRuntime(1010): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:45)
06-24 15:14:07.102: E/AndroidRuntime(1010): at org.apache.cordova.CordovaChromeClient.onJsPrompt(CordovaChromeClient.java:213)
06-24 15:14:07.102: E/AndroidRuntime(1010): at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:566)
06-24 15:14:07.102: E/AndroidRuntime(1010): at android.os.Handler.dispatchMessage(Handler.java:99)
06-24 15:14:07.102: E/AndroidRuntime(1010): at android.os.Looper.loop(Looper.java:123)
06-24 15:14:07.102: E/AndroidRuntime(1010): at android.app.ActivityThread.main(ActivityThread.java:4627)
06-24 15:14:07.102: E/AndroidRuntime(1010): at java.lang.reflect.Method.invokeNative(Native Method)
06-24 15:14:07.102: E/AndroidRuntime(1010): at java.lang.reflect.Method.invoke(Method.java:521)
06-24 15:14:07.102: E/AndroidRuntime(1010): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
06-24 15:14:07.102: E/AndroidRuntime(1010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
06-24 15:14:07.102: E/AndroidRuntime(1010): at dalvik.system.NativeStart.main(Native Method)

[/code]

 

But if I don't modify my import and if don't add the project SmartStore project, I've got the error : Class not found.

 

What is the problem with my project?

Aurélien LavalAurélien Laval

I've resolved my issue.

I've copy/paste the file "icudt46l.zip" in the folder "assets" of my project CloudTunes.

 

Thanks for your help.

Aurélien LavalAurélien Laval

Finally, it doesn't work cause I've an old version of "js".

When, I try to store offline, I've this error : JSON error in an alert box and W/SmartStorePlugin.execute(1190): is being called by js from older sdk, jsVersion: 1.4, nativeVersion: 1.5.3 in my console.

 

I do that :

[code]

function Track(){
   this.Id = null;
   this.Name = null;
   this.Price__c = null;
   this.Album__c = null;
}

 

var track = new Track();
track.Id = $j('#idInput').val();
track.Name = $j('#nameInput').val();
track.Price__c = $j('#priceInput').val();
track.Album__c = $j('#albumIdInput').val();

 

var myTable = [];
myTable.push(track);

 

var successAdd = function(message){
   alert("message : " + JSON.stringify(message));
}

var errorAdd = function(error){
   alert("error : " + error);
}

addOfflineTracks(JSON.stringify(myTable), successAdd, errorAdd);

[/code]

 

Why have I an old version of javascript (if it's javascript) whereas I've downloaded it this morning?