Tuesday, 19 January 2021

Cannot build React-native Marketing Cloud

Having issues when building react-native app using ./gradlew assembleRelease

I've installed react-native-marketing-cloud package

yarn add react-native-marketingcloudsdk

Added maven repo

maven { url "https://salesforce-marketingcloud.github.io/MarketingCloudSDK-Android/repository" }

Here's my MainApplication.java

package org.reactnative.example;

import android.app.Application;
import android.graphics.drawable.Drawable;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import com.salesforce.marketingcloud.MarketingCloudConfig;
import com.salesforce.marketingcloud.MarketingCloudSdk;
import com.salesforce.marketingcloud.notifications.NotificationCustomizationOptions;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import android.util.Log;
import androidx.multidex.MultiDexApplication;

public class MainApplication extends MultiDexApplication implements ReactApplication {

  private final ReactNativeHost mReactNativeHost =
      new ReactNativeHost(this) {
        @Override
        public boolean getUseDeveloperSupport() {
          return BuildConfig.DEBUG;
        }

        @Override
        protected List<ReactPackage> getPackages() {
          @SuppressWarnings("UnnecessaryLocalVariable")
          List<ReactPackage> packages = new PackageList(this).getPackages();
          // Packages that cannot be autolinked yet can be added manually here, for example:
          // packages.add(new MyReactNativePackage());
          return packages;
        }

        @Override
        protected String getJSMainModuleName() {
          return "index";
        }
      };

  @Override
  public ReactNativeHost getReactNativeHost() {
    return mReactNativeHost;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    MarketingCloudSdk.init(this,
      MarketingCloudConfig.builder()
        .setApplicationId("SECRET")
        .setAccessToken("SECRET")
        .setSenderId("SECRET")
        .setMarketingCloudServerUrl("SECRET")
        .setAnalyticsEnabled(true)
        .build(this),
      initializationStatus -> Log.e("INIT", initializationStatus.toString()));
    SoLoader.init(this, /* native exopackage */ false);
    initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
  }
}

As per docs, that's enough for working with that package

But getting this error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-marketingcloudsdk:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:161:5-169:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.
         
     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:194:5-204:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.
         
     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:213:5-221:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.
         
     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:238:5-241:13: AAPT: error: style attribute 'attr/layout_constraintDimensionRatio (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintDimensionRatio)' not found.
         
     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:250:5-260:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.
         
     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:272:5-280:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.
         
     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:295:5-298:13: AAPT: error: style attribute 'attr/layout_constraintDimensionRatio (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintDimensionRatio)' not found.
         
     /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml:315:5-325:13: AAPT: error: style attribute 'attr/layout_constraintWidth_max (aka com.salesforce.marketingcloud.reactnative:attr/layout_constraintWidth_max)' not found.
         

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.2/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 2m 24s
576 actionable tasks: 523 executed, 53 up-to-date

Here's that file /Users/apple/.gradle/caches/transforms-2/files-2.1/e7913c710c1c6a7686781b3ec2a08a9b/jetified-marketingcloudsdk-7.3.1/res/values/values.xml

Not sure what's the problem



from Cannot build React-native Marketing Cloud

No comments:

Post a Comment