We are working on integrating a third party library with Android native on React Native. While building the project we are getting autogenerated BuildConfig.class generated multiple times in 2 different *.jar files. The error message reads as follows:
~/app-consumer/android/app/build/intermediates/transforms/FirebasePerformancePlugin/release/222.jar: R8: Type com.moengage.react.BuildConfig is defined multiple times: ~/app-consumer/android/app/build/intermediates/transforms/FirebasePerformancePlugin/release/222.jar:com/moengage/react/BuildConfig.class, ~/app-consumer/android/app/build/intermediates/transforms/FirebasePerformancePlugin/release/223.jar:com/moengage/react/BuildConfig.class
The settings.gradle looks like:
include ':react-native-moengage'
project(':react-native-moengage').projectDir = new File(rootProject.projectDir, '../node_modules/@development-team20/react-native-moengage-retailo/android')
The app/build.gradle look like:
dependencies {
implementation project(':react-native-moengage')
implementation("com.moengage:moe-android-sdk:11.4.02")
}
The MainApplication.java file look like:
import com.moengage.react.MoEReactPackage;
import com.moengage.core.MoEngage;
import com.moe.pushlibrary.MoEHelper;
import com.moengage.react.MoEInitializer;
import com.moengage.firebase.MoEFireBaseHelper;
import com.moengage.core.config.NotificationConfig;
import com.moengage.pushbase.MoEPushHelper;
import com.moengage.core.config.LogConfig;
import com.moengage.core.LogLevel;
import com.moengage.core.MoEngage;
import com.moengage.core.DataCenter;
public class MainApplication extends Application implements ReactApplication {
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
MoEngage moEngage =
new MoEngage.Builder(this,BuildConfig.MOENGAGE_API_KEY)
.configureNotificationMetaData(new NotificationConfig(R.drawable.ic_stat_onesignal_default, R.drawable.ic_stat_onesignal_default, R.color.orange_200, null, true, false, true))
.configureLogs(new LogConfig(LogLevel.VERBOSE, true))
.setDataCenter(DataCenter.DATA_CENTER_3)
.build();
MoEngage.initialise(moEngage);
}
}
We have tried modifying the name of this library package but that also didn't work. This is happening on CI pipeline server as well which starts building from scratch so it is not supposed to be the problem resolved by cleaning gradle or restarting gradle.