2

I am receiving a difficult to debug error upon application start up. I have recently updated the sales force sdk from

'com.exacttarget.etpushsdk:etsdk:4.9.4@aar'

to

'com.salesforce.marketingcloud:marketingcloudsdk:5.1.3'

Notifications seem to appear sometimes, however more frequently upon app startup I am seeing the same Illegal state exception happening from inside the MarketingCloudSDK.

Init code:

            MarketingCloudSdk.init(ShowtimeApplication.instance, getSalesForceConfig().build() , new MarketingCloudSdk.InitializationListener() {
            @Override
            public void complete(InitializationStatus initializationStatus) {
                if (!initializationStatus.isUsable()){
                    UberLog.e("MarkingCloudSdk", " Initialization error" , " Status: " + initializationStatus.toString());
                    return;
                }
            }
        });

Builder retreival:

    @NonNull
private MarketingCloudConfig.Builder getSalesForceConfig() {
    MarketingCloudConfig.Builder configbuilder = MarketingCloudConfig.builder();
    configbuilder.setApplicationId(mEtAppId)
            .setAccessToken(mEtAccessToken)
            .setGcmSenderId(mGcmProjectNumber)
            .setAnalyticsEnabled(true)    // ET Analytics, default = false
            .setPiAnalyticsEnabled(true)         // Web & Mobile Analytics, default = false
            .setGeofencingEnabled(false)
            .setNotificationSmallIconResId(R.drawable.ic_stat_notify)
            .setNotificationBuilder(new NotificationManager.NotificationBuilder() {
                @Override
                public NotificationCompat.Builder setupNotificationBuilder(@NonNull Context context, @NonNull NotificationMessage notificationMessage) {
                    UberLog.i("MarketingCloud", "Notification builder");
                    NotificationMessage message = notificationMessage;
                    //  String title = message.payload().getString("title",null) == null ? message.payload().getString("title",null): message.title();
                    // String subtitle = message.payload().getString("subtitle",null) == null ? message.payload().getString("subtitle",null): message.alert();
                    String mess = message.alert();
                    NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
                    builder.setSmallIcon(R.drawable.ic_stat_notify);
                    // builder.setContentTitle(title);
                    builder.setContentText(mess);
                    //  builder.setSubText(subtext);

                    // the notification builder is returned here.
                    return builder;
                }
            })
            .setNotificationLaunchIntentProvider(this);
    return configbuilder;
}

The Exception I am seeing on multiple devices upon application install and run:

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.showtime.standalone, PID: 30469
              java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/user/0/[APPPACKAGE]/databases/storagedb.db
                  at android.database.sqlite.SQLiteClosable.acquireReference(SQLiteClosable.java:55)
                  at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1268)
                  at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1144)
                  at com.salesforce.marketingcloud.d.a.c.a(Unknown Source)
                  at com.salesforce.marketingcloud.d.a.c.a(Unknown Source)
                  at com.salesforce.marketingcloud.d.a.c.a(Unknown Source)
                  at com.salesforce.marketingcloud.d.a.e.a(Unknown Source)
                  at com.salesforce.marketingcloud.messages.RegionMessageManager.f(Unknown Source)
                  at com.salesforce.marketingcloud.messages.RegionMessageManager.a(Unknown Source)
                  at com.salesforce.marketingcloud.b.c.a(Unknown Source)
                  at com.salesforce.marketingcloud.b.c.a(Unknown Source)
                  at com.salesforce.marketingcloud.b.c$a.onReceive(Unknown Source)
                  at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
                  at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
                  at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:148)
                  at android.app.ActivityThread.main(ActivityThread.java:5525)
                  at java.lang.reflect.Method.invoke(Native Method)
                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)

Any suggestions? Thanks

  • I was initializing the sdk more than once, once I stopped that happening this error didn't appear again. I hope this helps someone else! – Mike Docherty Mar 19 '18 at 19:58
  • Re-initializing v5.x versions of the SDK should not present a problem. Question: from where are you initializing the SDK? It should be initialized in your application's Application Class' onCreate method. Failing to do so will also lead to another problem you alluded to "notifications seem to appear sometimes." – Bill Mote Jun 5 '18 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.