I'm attempting to expand our basic implementation of the Marketing Cloud SDK in our Android app. We've successfully been using it to send push notifications, and are now adding some attributes so we can better target them.

Following the documentation here: http://salesforce-marketingcloud.github.io/JB4A-SDK-Android/features/attributes.html with version 5.3.0 of the marketing cloud SDK I attempted to create a new Attribute object using the static create method contained within.

Attribute attr = Attribute.create("key", "value");

However, Android Studio is complaining that the method doesn't exist, and asking it to open the source for the Attribute class does not show the method in the decompiled class.

Am I being prevented from using this method due to a proguard configuration or is there something else preventing the method from showing up in 5.3.0?

1 Answer 1


Amazing that this hasn't come up before. Thank you. You are correct: the create() method is being obfuscated and is marked for internal-use-only. I will open a ticket for this to be addressed.

You can, however, get an instance of RegistrationManager.Editor and set/clear Attributes, add/remove Tags and set ContactKey:

MarketingCloudSdk.requestSdk(new MarketingCloudSdk.WhenReadyListener() {
    public void ready(MarketingCloudSdk sdk) {
        RegistrationManager.Editor editor = sdk.getRegistrationManager().edit();
        editor.setAttribute("someAttribute", "someValue");
        editor.setAttribute("someOtherAttribute", "someOtherValue");
        editor.addTags("someTag", "someOtherTag");
        editor.commit(); // This will initiate a Contact/Registration Update with the Marketing Cloud Servers

            Caution: Never set an Attribute, Tag or ContactKey to an ever changing value like a timestamp
            unless your UI is visible; doing so in your Application's onCreate() can result unnecessary
            application wakes and additional network traffic.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .