0

In native Android application, I have this release build crash, related to the SalesForce Marketing cloud SDK implementation:

Fatal Exception: java.lang.IllegalAccessError: Method 'boolean com.salesforce.marketingcloud.a.a$a.a(com.salesforce.marketingcloud.f.j)' is inaccessible to class 'com.salesforce.marketingcloud.i$d' (declaration of 'com.salesforce.marketingcloud.i$d' appears in /data/app/somepackage-1/base.apk:classes2.dex)
   at com.salesforce.marketingcloud.a.b.b(b.java)
   at com.salesforce.marketingcloud.a.b.c(b.java)
   at com.salesforce.marketingcloud.registration.e.b(e.java)
   at com.salesforce.marketingcloud.registration.e.(Unknown Source)
   at com.salesforce.marketingcloud.registration.d.b(d.java)
   at com.salesforce.marketingcloud.registration.d.b(d.java)
   at com.salesforce.marketingcloud.MarketingCloudSdk.d(MarketingCloudSdk.java)
   at com.salesforce.marketingcloud.MarketingCloudSdk.getInstance(MarketingCloudSdk.java)
   at com.salesforce.marketingcloud.MarketingCloudSdk$1.run(MarketingCloudSdk.java)
   at java.lang.Thread.run(Thread.java:761)

which I suppose it's coming from the proguard rules in my project, because when I switch OFF proguard the crash doesn't appear any more.

I am using SF SDK marketing cloud ver. 6.2.2

Any recommendation for the right SF SDK proguard rules are appreciated.

Thanks in advance

Update:

The app crashes right after I run

MarketingCloudSdk.init(application, marketingCloudConfiguration)

My build configuration looks like this:

val marketingCloudAppId = "some_app_id"
val marketingAccessToken = "some_token"
val senderId = "firebase_sender_id"
val serverUrl = "some_url"
val mid = "1234567"
val notificationCustomisationOptions = createNotificationCustomisationOptions()

val marketingCloudConfiguration = MarketingCloudConfig.builder()
.setApplicationId(marketingCloudAppId)
.setAccessToken(marketingAccessToken)
.setSenderId(senderId)
.setMarketingCloudServerUrl(serverUrl)
.setMid(mid)
.setNotificationCustomizationOptions(notificationCustomisationOptions)
.setAnalyticsEnabled(true)
.setPiAnalyticsEnabled(true)
.build(application)

The proguard looks like this:

-keep class com.comscore.** { *; }
-dontwarn com.comscore.**
-keep public class com.google.android.gms.ads.** { public *; }
-keep public class com.google.ads.** { public *; }
-keepattributes *Annotation*
-keepclassmembers class ** {
    @org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
    <init>(java.lang.Throwable);
}
-keep class androidx.appcompat.widget.SearchView { *; }
-keepclassmembers class com.ebay.app.common.fragments.ZoomImageViewSwipeNavFragment {
    public void onMessageSuccess(**);
    public void onParallelMessageSuccess(**);
}
-keep public class com.ebay.app.common.push.fcm.EcgFcmListenerService { *; }
-keep public class com.ebay.app.common.push.fcm.EcgFcmServerMessages { *; }
-keep public class com.ebay.app.common.push.fcm.EcgFcmReceiver { *; }
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    !static !transient <fields>;
    !private <fields>;
    !private <methods>;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}
-keep interface org.simpleframework.xml.core.Label { public *;}
-keep class * implements org.simpleframework.xml.core.Label { public *;}
-keep interface org.simpleframework.xml.core.Parameter { public *;}
-keep class * implements org.simpleframework.xml.core.Parameter { public *;}
-keep interface org.simpleframework.xml.core.Extractor { public *;}
-keep class * implements org.simpleframework.xml.core.Extractor { public *;}
-keep interface org.simpleframework.xml.convert.Convert { public *;}
-keep class * implements org.simpleframework.xml.convert.Converter { public *;}
-keepattributes *Annotation*
-keepattributes InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,EnclosingMethod,Attribute,Element,Root
-keepclassmembers class * {
    @org.simpleframework.xml.* *;
}
-keep class com.tickaroo.tikxml.** { *; }
-keep @com.tickaroo.tikxml.annotation.Xml public class *
-keep class **$$TypeAdapter { *; }
-keepclasseswithmembernames class * {
    @com.tickaroo.tikxml.* <fields>;
}
-keepclasseswithmembernames class * {
    @com.tickaroo.tikxml.* <methods>;
}
-dontwarn com.google.android.gms.**
-keep public class com.google.android.gms.**
-dontwarn com.apptentive.android.sdk.**
-keep class com.apptentive.android.sdk.** { *; }
-keep class sun.misc.Unsafe { *; }
-keep class com.ebay.app.common.categories.models.** { *; }
-keep class com.ebay.app.common.location.models.** { *; }
-keep class com.ebay.app.common.models.** { *; }
-keep class com.ebay.app.common.models.ad.** { *; }
-keep class com.ebay.app.common.models.ad.extendedInfo.** { *; }
-keep class com.ebay.app.common.models.ad.raw.** { *; }
-keep class com.ebay.app.common.models.raw.** { *; }
-keep class com.ebay.app.contactPoster.models.** { *; }
-keep class com.ebay.app.messageBox.models.** { *; }
-keep class com.ebay.app.search.models.** { *; }
-keep class com.ebay.app.userAccount.register.models.** { *; }
-keep class com.ebay.app.userAccount.models.** { *; }
-keep class com.ebay.app.contactPoster.models.raw.** { *; }
-keep class com.ebay.app.common.analytics.ebayTracking.** { *; }
-keep class com.ebay.app.featurePurchase.models.raw.** { *; }
-keep class com.ebay.app.featurePurchase.models.worldPay.raw.** { *; }
-keep class com.ebay.app.featurePurchase.models.** { *; }
-keep class com.ebay.app.recommendations.** { *; }
-keep class com.ebay.app.common.networking.papiDataModels.** { *; }
-keep class com.ebay.app.externalPartner.models.treebay.** { *; }
-keep class com.ebay.app.flagAds.models.raw.** { *; }
-keep class com.ebay.app.search.map.models.** { *; }
-keep class com.ebay.smaato.networking.model.** { *; }
-keep class com.bumptech.glide.integration.okhttp3.OkHttpGlideModule { *; }
-keep class com.ebay.app.common.glide.EcgGlideModule { *; }
-keep class com.adjust.sdk.** { *; }
-keep class com.google.android.gms.common.** { *; }
-keep class com.google.android.gms.ads.identifier.** { *; }
-dontwarn rx.**
-dontwarn retrofit2.**
-dontwarn okio.**
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-keep class retrofit2.** { *; }
-keepclasseswithmembers class * {
    @retrofit2.http.* <methods>;
}
-keep class **.R$* {
    <fields>;
}
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-ignorewarnings
-keepnames class com.google.gson.Gson
-keepnames class org.json.** { *; }
-dontwarn com.fasterxml.jackson.**
-dontwarn org.json.**
-dontwarn javax.annotation.**
-dontwarn edu.umd.cs.findbugs.annotations.SuppressFBWarnings
-dontwarn org.slf4j.**
-keep class com.ebay.app.abTesting.firebase.model.** { *; }
-keep class com.ebay.app.abTesting.firebase.** { *; }
-keep class com.google.firebase.perf.** { *; }
-keep class com.ebay.algolia.models.** { *; }
-dontwarn com.algolia.**
-keep class org.prebid.mobile.** { *; }
-keep class com.google.android.gms.ads.doubleclick.PublisherAdRequest {
   public *;
}
-keepclassmembers class com.mopub.** { public *; }
-keep public class com.mopub.**
-keep public class android.webkit.JavascriptInterface {}
-keep class * extends com.mopub.mobileads.CustomEventBanner {}
-keep class * extends com.mopub.mobileads.CustomEventInterstitial {}
-keep class * extends com.mopub.nativeads.CustomEventNative {}
-keep class * extends com.mopub.nativeads.CustomEventRewardedAd {}
-keepclassmembers class ** { @com.mopub.common.util.ReflectionTarget *; }
-keepclassmembers class com.integralads.avid.library.mopub.** { public *; }
-keep public class com.integralads.avid.library.mopub.**
-keepclassmembers class com.moat.analytics.mobile.mpub.** { public *; }
-keep public class com.moat.analytics.mobile.mpub.**
-keep class com.google.android.gms.common.GooglePlayServicesUtil {*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {*;}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {*;}
-keep class * extends java.util.ListResourceBundle {
    protected Object[][] getContents();
}
-keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable {
    public static final *** NULL;
}
-keepnames @com.google.android.gms.common.annotation.KeepName class *
-keepclassmembernames class * {
    @com.google.android.gms.common.annotation.KeepName *;
}
-keepnames class * implements android.os.Parcelable {
    public static final ** CREATOR;
}
-ignorewarnings
-keep class com.threatmetrix.TrustDefender.internal.** { *; }
-keep class com.threatmetrix.TrustDefender.** { *; }
-dontwarn com.threatmetrix.TrustDefender.**
-dontwarn androidx.annotation.NonNull
-dontwarn androidx.annotation.Nullable
-dontwarn androidx.annotation.RequiresApi
  • Do you know the steps to reproduce this error? I can successfully compile, launch and use SDK v6.2.2 with minifyEnabled true set for my builds. – Bill Mote Jun 5 '19 at 15:08
  • Thanks @BillMote for looking into this. My project has a lot of dependencies and also custom proguard rules. I will update the post about that. About the steps, all I have to do is to run the code to initialise the SDK MarketingCloudSdk.init(application, marketingCloudConfiguration) and the app crashes – Stoycho Andreev Jun 5 '19 at 21:26
  • 1
    Using the default new project rules does not encounter this problem. Integrating the SDK into a project with a custom ProGuard rules file does not encounter this problem. You should create an investigation through your support representative. – Bill Mote Jun 6 '19 at 13:12
  • Thanks @BillMote, I will – Stoycho Andreev Jun 10 '19 at 13:11
0

The issue lies in the version of the Android Gradle plugin and the use of the R8 (default with version 3.4.0 and higher). You can resolve using version 3.3.0 of the Android Gradle Plugin, in your project build.gradle file:

 buildscript {
    repositories {
        ...}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
        ...
    }
}

or using the last version of the Android Gradle Plugin but disabling R8 in your gradle.properties file:

android.enableR8=false
| improve this answer | |
  • But that anyway is not suggested. Should try to make this work with R8 enabled. – sud007 Jul 2 at 9:02

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.