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
Gaurav GulanjkarGaurav Gulanjkar 

Smartstore Error

Hi,

I am developing a hybrid mobile app using smartstore.I am using the latest Smartstore library 2.01.When i run the application in simulator my app is crashing without displaying any page.Following is the log cat:

02-11 12:42:47.749: I/dalvikvm(346): Could not find method android.app.admin.DevicePolicyManager.getStorageEncryptionStatus, referenced from method com.salesforce.androidsdk.security.Encryptor.init
02-11 12:42:47.749: W/dalvikvm(346): VFY: unable to resolve virtual method 124: Landroid/app/admin/DevicePolicyManager;.getStorageEncryptionStatus ()I
02-11 12:42:47.758: D/dalvikvm(346): VFY: replacing opcode 0x6e at 0x001d
02-11 12:42:47.758: D/dalvikvm(346): VFY: dead code 0x0020-0029 in Lcom/salesforce/androidsdk/security/Encryptor;.init (Landroid/content/Context;)Z
02-11 12:42:47.788: D/HttpAccess:constructor(346): User-Agent string: SalesforceMobileSDK/2.1.0 android mobile/2.3.3 (sdk) myWDApp/1.0 Hybrid
02-11 12:42:47.948: I/SalesforceDroidGapActivity.onCreate(346): onCreate called
02-11 12:42:47.998: D/AndroidRuntime(346): Shutting down VM
02-11 12:42:47.998: W/dalvikvm(346): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-11 12:42:48.029: E/AndroidRuntime(346): FATAL EXCEPTION: main
02-11 12:42:48.029: E/AndroidRuntime(346): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.verticurl.mywd/com.salesforce.androidsdk.ui.sfhybrid.SalesforceDroidGapActivity}: java.lang.SecurityException: caller uid 10006 lacks any of android.permission.GET_ACCOUNTS
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.os.Looper.loop(Looper.java:123)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-11 12:42:48.029: E/AndroidRuntime(346):  at java.lang.reflect.Method.invokeNative(Native Method)
02-11 12:42:48.029: E/AndroidRuntime(346):  at java.lang.reflect.Method.invoke(Method.java:507)
02-11 12:42:48.029: E/AndroidRuntime(346):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-11 12:42:48.029: E/AndroidRuntime(346):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-11 12:42:48.029: E/AndroidRuntime(346):  at dalvik.system.NativeStart.main(Native Method)
02-11 12:42:48.029: E/AndroidRuntime(346): Caused by: java.lang.SecurityException: caller uid 10006 lacks any of android.permission.GET_ACCOUNTS
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.os.Parcel.readException(Parcel.java:1322)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.os.Parcel.readException(Parcel.java:1276)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.accounts.IAccountManager$Stub$Proxy.getAccounts(IAccountManager.java:475)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.accounts.AccountManager.getAccountsByType(AccountManager.java:373)
02-11 12:42:48.029: E/AndroidRuntime(346):  at com.salesforce.androidsdk.rest.ClientManager.getAccount(ClientManager.java:188)
02-11 12:42:48.029: E/AndroidRuntime(346):  at com.salesforce.androidsdk.rest.ClientManager.peekRestClient(ClientManager.java:138)
02-11 12:42:48.029: E/AndroidRuntime(346):  at com.salesforce.androidsdk.ui.sfhybrid.SalesforceDroidGapActivity.onCreate(SalesforceDroidGapActivity.java:118)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-11 12:42:48.029: E/AndroidRuntime(346):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-11 12:42:48.029: E/AndroidRuntime(346):  ... 11 more
Ashish_SFDCAshish_SFDC
Hi Gaurav, 


I've seen this as well on some devices, it appears to be device/os dependent add CookieSyncManager.createInstance(this) to your ForceApp subclass's onCreate method.

https://github.com/forcedotcom/SalesforceMobileSDK-Android/issues/26


Regards,
Ashish

Gaurav GulanjkarGaurav Gulanjkar
Hey Ashish thanks for replying..

I have already added CookieSyncManager.createInstance(this) in my class under onCreate() following is the code in class for reference

package com.verticurl.mywd;

import android.app.Application;
import android.webkit.CookieSyncManager;

import com.salesforce.androidsdk.smartstore.app.SalesforceSDKManagerWithSmartStore;

/**
* Application class for the myWDApp app.
*/
public class myWDAppApp extends Application {

@Override
public void onCreate() {
  super.onCreate();
  SalesforceSDKManagerWithSmartStore.initHybrid(getApplicationContext(), new KeyImpl());
  CookieSyncManager.createInstance(this);
  /*
   * Un-comment the line below to enable push notifications in this app.
   * Replace 'pnInterface' with your implementation of 'PushNotificationInterface'.
   * Add your Google package ID in 'bootonfig.json', as the value
   * for the key 'androidPushNotificationClientId'.
   */
  // SalesforceSDKManagerWithSmartStore.getInstance().setPushNotificationReceiver(pnInterface);
}
}
Gaurav GulanjkarGaurav Gulanjkar
I have added the code in the SDK
Ashish_SFDCAshish_SFDC
Hi Gaurav, 


Its saying the User does not have permissions to get accouts, 

02-11 12:42:48.029: E/AndroidRuntime(346): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.verticurl.mywd/com.salesforce.androidsdk.ui.sfhybrid.SalesforceDroidGapActivity}: java.lang.SecurityException: caller uid 10006 lacks any of android.permission.GET_ACCOUNTS

Check the same. 


Regards,
Ashish
Gaurav GulanjkarGaurav Gulanjkar
Hi,

I have given both the permission's GET_ACCOUNTS and MANAGE_ACCOUNTS.Now there are no errors and the appliaction is launched but it just gets refreshed all the time no login page is displayed.

Thanks,
Gaurav
Gaurav GulanjkarGaurav Gulanjkar
At the end i got a pop up saying Activity () is not responding
Ashish_SFDCAshish_SFDC
Hi Gaurav, 


Can you post the exact error and if needed a screenshot via tinypic.com. 


Regards,
Ashish
Gaurav GulanjkarGaurav Gulanjkar
Hi Ashish,

Following is the Log Cat I am getting,The app just gets refreshed all the time with the folllowing set of logcat's:

02-14 18:27:43.260: I/ClientManager:peekRestClient(367): No user account found
02-14 18:27:43.260: I/ClientManager:peekRestClient(367): com.salesforce.androidsdk.rest.ClientManager$AccountInfoNotFoundException: No user account found
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at com.salesforce.androidsdk.rest.ClientManager.peekRestClient(ClientManager.java:140)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at com.salesforce.androidsdk.ui.sfhybrid.SalesforceDroidGapActivity.onCreate(SalesforceDroidGapActivity.java:118)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at android.os.Looper.loop(Looper.java:123)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at java.lang.reflect.Method.invokeNative(Native Method)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at java.lang.reflect.Method.invoke(Method.java:507)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-14 18:27:43.260: I/ClientManager:peekRestClient(367):  at dalvik.system.NativeStart.main(Native Method)
02-14 18:27:43.292: I/ActivityManager(76): Displayed com.wd.verticurl/com.salesforce.androidsdk.ui.sfhybrid.SalesforceDroidGapActivity: +1s646ms (total +344ms)
02-14 18:27:44.120: I/SalesforceDroidGapActivity.onResumeNotLoggedIn(367): Should authenticate / online - authenticating
02-14 18:27:44.120: I/SalesforceDroidGapActivity.authenticate(367): authenticate called
02-14 18:27:44.130: I/ClientManager:getRestClient(367): No account of type com.salesforce.androisdk found
02-14 18:27:44.150: D/AccountManagerService(76): bind attempt failed for Session: expectLaunch true, connected false, stats (0/0/0), lifetime 0.001, addAccount, accountType com.salesforce.androisdk, requiredFeatures null
02-14 18:27:44.260: W/AccMgrCallback:run(367): android.accounts.AuthenticatorException: bind failure
02-14 18:27:44.260: W/AccMgrCallback:run(367):  at android.accounts.AccountManager.convertErrorToException(AccountManager.java:1437)
02-14 18:27:44.260: W/AccMgrCallback:run(367):  at android.accounts.AccountManager.access$400(AccountManager.java:138)
02-14 18:27:44.260: W/AccMgrCallback:run(367):  at android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:1283)
02-14 18:27:44.260: W/AccMgrCallback:run(367):  at android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69)
02-14 18:27:44.260: W/AccMgrCallback:run(367):  at android.os.Binder.execTransact(Binder.java:320)
02-14 18:27:44.260: W/AccMgrCallback:run(367):  at dalvik.system.NativeStart.run(Native Method)
02-14 18:27:44.260: I/SalesforceDroidGapActivity.authenticate(367): authenticatedRestClient called with null client
02-14 18:27:44.341: I/ActivityManager(76): Starting: Intent { flg=0x10000000 cmp=com.wd.verticurl/com.salesforce.androidsdk.ui.sfhybrid.SalesforceDroidGapActivity } from pid 367
02-14 18:27:44.630: D/dalvikvm(367): GC_CONCURRENT freed 660K, 63% free 2972K/7943K, external 1625K/2137K, paused 5ms+33ms
02-14 18:27:44.870: I/SalesforceDroidGapActivity.onCreate(367): onCreate called

Thanks,
Gaurav
Ashish_SFDCAshish_SFDC
HI Gaurav, 


static class ClientManager.AccountInfoNotFoundException

->          Exception thrown when no account could be found (during a peekRestClient call)

http://forcedotcom.github.io/SalesforceMobileSDK-Android/com/salesforce/androidsdk/rest/ClientManager.html


Regards,
Ashish
Gaurav GulanjkarGaurav Gulanjkar
Hi Ashish,

I am not able to figure out how to resolve the problem.Do i have to create an instance of the ClientManager class and createNewAccount.
I am creating a custom hybrid app for my portal users who already have an account.I want them to use the same login credentails which they are using to login to the website to login to my custom app aswell.Please help.
Ashish_SFDCAshish_SFDC
Hi Gaurav, 


See the notes below for similar issues, 

I had the same problem. You need to set manifestmerger.enabled=true in your project.properties in order to merge the manifest file from salesforceSDK. The AuthenticatorService from that manifest fixes the problem.

http://stackoverflow.com/questions/20417235/not-able-to-launch-android-hybrid-app-using-salesforce-mobile-sdk

Do you get the same error while running on emu as well as device? Did you follow all steps mentioned in Android Readme? You need to have a connected app with scope set of "web" and "api".
This looks to be a scoping issue to me.

https://developer.salesforce.com/forums/?id=906F00000009AKbIAM

com.salesforce.androidsdk.rest
Class ClientManager

http://forcedotcom.github.io/SalesforceMobileSDK-Android/com/salesforce/androidsdk/rest/ClientManager.html


Regards,
Ashish