如何使用salesforce SDK在android中创建智能商店表

时间:2017-04-17 12:34:26

标签: java android salesforce salesforce-service-cloud salesforce-ios-sdk

我使用的是salesforce doc中的以下源代码,但它给了我一个    低于错误。我怎么能解决它,任何人都可以帮助我。

   SmartStoreSDKManager sdkManager = SmartStoreSDKManager.getInstance();
   SmartStore mSmartStore = sdkManager.getSmartStore();


  private void createSoup() {

    IndexSpec[] ACCOUNTS_INDEX_SPEC = {
            new IndexSpec("Name",    SmartStore.Type.string),
            new IndexSpec("Id",      SmartStore.Type.string),
            new IndexSpec("OwnerId", SmartStore.Type.string)
    };
    mSmartStore.registerSoup(ACCOUNTS_SOUP, ACCOUNTS_INDEX_SPEC);
 }

当我在调用此方法时,它会向我显示以下内容     异常。

  

FATAL EXCEPTION:主程序:com.runtime,PID:7033       java.lang.RuntimeException:无法启动活动       ComponentInfo {com.runtime / com.runtime.activity.home.HomeActivity}:       java.lang.ClassCastException:       com.salesforce.androidsdk.app.SalesforceSDKManager无法强制转换为       com.salesforce.androidsdk.smartstore.app.SmartStoreSDKManager at       android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)       在       android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)       在android.app.ActivityThread.access $ 800(ActivityThread.java:141)       在       android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1212)       在android.os.Handler.dispatchMessage(Handler.java:102)at       android.os.Looper.loop(Looper.java:136)at       android.app.ActivityThread.main(ActivityThread.java:5052)at       java.lang.reflect.Method.invokeNative(Native Method)at       java.lang.reflect.Method.invoke(Method.java:515)at       com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:796)       在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)at       dalvik.system.NativeStart.main(Native方法)引起:       java.lang.ClassCastException:       com.salesforce.androidsdk.app.SalesforceSDKManager无法强制转换为       com.salesforce.androidsdk.smartstore.app.SmartStoreSDKManager at       com.salesforce.androidsdk.smartstore.app.SmartStoreSDKManager.getInstance(SmartStoreSDKManager.java:132)       在       com.runtime.activity.home.HomeActivity.setDefualtConfiguration(HomeActivity.java:163)       在       com.runtime.activity.home.HomeActivity.onCreate(HomeActivity.java:82)       在android.app.Activity.performCreate(Activity.java:5242)处       android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)       在       android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)       在       android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2249)       在android.app.ActivityThread.access $ 800(ActivityThread.java:141)       在       android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1212)       在android.os.Handler.dispatchMessage(Handler.java:102)at       android.os.Looper.loop(Looper.java:136)at       android.app.ActivityThread.main(ActivityThread.java:5052)at       java.lang.reflect.Method.invokeNative(Native Method)

1 个答案:

答案 0 :(得分:0)

经过大量的文件阅读后,我找到了解决方案。

在我的应用文件onCreate方法中,只需执行此更改。

  //SalesforceSDKManager.initNative(getApplicationContext(), new NativeKeyImpl(), SplashActivity.class);

  Comment the above line of code and put this line of code.

  SmartSyncSDKManager.initNative(getApplicationContext(), new NativeKeyImpl(), SplashActivity.class);

   This line of code initialise smartstore SDK. The problem is soved