<!--- Hello there you awesome person; Please note that the issue list of this repo is exclusively for bug reports;
<!-- NOTE: You can change any of the [ ]
to [x]
to mark an option(s) as selected -->
<!-- PLEASE DO NOT REMOVE ANY SECTIONS FROM THIS ISSUE TEMPLATE --> <!-- Leave them as they are even if they're irrelevant to your issue -->
<!-- Please describe your issue here --^ and provide as much detail as you can. -->
<!-- Include code snippets that show your usages of the library in the context of your project. --> <!-- Snippets that also show how and where the library is imported in JS are useful to debug issues relating to importing or methods not found issues -->
Describe your issue here I am currently moving my Android project to RN 0.60.0, and trying to take care along the way.
I have got to a point where my project will build and run on my device, and then crashes because of missing Firebase libraries (this makes sense, because at this point I haven't included the libraries yet in my Android project.
But, as soon as I include the implementation project(':react-native-firebase')
in my build.gradle
file, my build fails with the error
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':app:mergeLibDexDevDebug'. A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Program type already present: io.invertase.firebase.BuildConfig Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
I am unsure how to overcome this issue, or why its exactly happening. From what the help in the errors tell me, its due to a 'duplicate class' (potentially) but Im not sure why or how at this point.
<!-- Provide the contents of key project files which will help to debug -->
<!-- For Example: -->
<!-- - iOS: Podfile
contents. -->
<!-- - Android: android/build.gradle
contents. -->
<!-- - Android: android/app/build.gradle
contents. -->
<!-- - Android: AndroidManifest.xml
contents. -->
<!-- ADD THE CONTENTS OF THE FILES IN THE PROVIDED CODE BLOCKS BELOW -->
<details><summary>Click To Expand</summary> <p>
ios/Podfile
:# N/A
AppDelegate.m
:// N/A
</p> </details>
<details><summary>Click To Expand</summary> <p>
<!--- Mark any options that apply below -->
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
compileSdkVersion = 28
buildToolsVersion = '28.0.3'
minSdkVersion = 21
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesVersion = "16.+"
firebaseVersion = "17.6.0"
}
repositories {
google()
maven {
url 'https://maven.fabric.io/public'
}
maven {
url 'https://plugins.gradle.org/m2/'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.1'
classpath 'io.fabric.tools:gradle:1.28.1'
classpath 'com.google.firebase:perf-plugin:1.2.1'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.5'
}
}
allprojects {
repositories {
mavenLocal()
maven {
url "$rootDir/../node_modules/react-native/android"
}
maven {
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
subprojects { subproject ->
afterEvaluate{
if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
wrapper {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
android/app/build.gradle
:apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: "com.android.application"
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: "io.fabric"
project.ext.envConfigFiles = [
devdebug: ".env.debug",
devrelease: ".env.debug",
productionrelease: ".env.production",
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.android.build.OutputFile
import com.google.gms.googleservices.GoogleServicesPlugin
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
//apply from: "../../node_modules/react-native-sentry/sentry.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
def useIntlJsc = false
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
flavorDimensions "versionCode"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.app"
resValue "string", "build_config_package", "com.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 132
versionName "1.2.0"
ndk {
abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a'
}
testBuildType System.getProperty('testBuildType', 'debug')
missingDimensionStrategy "minReactNative", "minReactNative46"
testInstrumentationRunner "android .support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
resValue "string", "app_name", "app"
signingConfig signingConfigs.release
buildConfigField "String", "CODEPUSH_KEY", '"xxxx"'
buildConfigField "String", "ADYEN_PUBLIC_KEY", '"xxxxx"'
}
debug {
resValue "string", "app_name", "app DEV"
debuggable true
buildConfigField "String", "CODEPUSH_KEY", '"xxxx"'
buildConfigField "String", "ADYEN_PUBLIC_KEY", '"xxxxx"'
}
}
flavorDimensions "standard"
productFlavors{
dev {
applicationId "com.app.development"
dimension "standard"
}
production {
applicationId "com.app"
dimension "standard"
}
}
dexOptions {
preDexLibraries = false
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation project(':react-native-code-push')
implementation project(':react-native-splash-screen')
implementation project(':react-native-firebase')
// implementation "com.google.firebase:firebase-core:17.2.0"
// implementation "com.google.firebase:firebase-database:19.0.0"
// implementation ("com.google.firebase:firebase-auth:19.0.0") {
// exclude group: "com.google.android.gms"
// }
// implementation "com.google.firebase:firebase-perf:19.0.0"
// implementation "com.google.firebase:firebase-functions:19.0.1"
// implementation "com.google.firebase:firebase-messaging:20.0.0"
// implementation "com.google.firebase:firebase-storage:19.0.0"
// implementation "com.google.firebase:firebase-firestore:21.0.0"
// implementation "com.google.firebase:firebase-dynamic-links:19.0.0"
// implementation "com.google.firebase:firebase-invites:17.0.0"
implementation "com.adyen.checkout:drop-in:3.1.1"
implementation "com.adyen.checkout:card-ui:3.1.1"
implementation "com.adyen.checkout:ideal-ui:3.1.1"
implementation 'com.facebook.react:react-native:0.60.0'
implementation "com.google.android.gms:play-services-base:17.1.0"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
if (useIntlJsc) {
implementation 'org.webkit:android-jsc-intl:+'
} else {
implementation 'org.webkit:android-jsc:+'
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle")
applyNativeModulesAppBuildGradle(project)
googleServices { disableVersionCheck = true }
android/settings.gradle
:rootProject.name = 'app'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings)
include ':app', ':react-native-code-push'
project(':react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-code-push/android/app')
include ':react-native-firebase'
project(':react-native-firebase').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-firebase/android')
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-splash-screen'
project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android')
include ':app'
MainApplication.java
:import android.app.Application;
import com.facebook.react.ReactApplication;
import com.facebook.react.PackageList;
import org.devio.rn.splashscreen.SplashScreenReactPackage;
import com.microsoft.codepush.react.CodePush;
import com.klikkie.shareManager.SharePackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.klikkie.adyenReactNative.AdyenPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
packages.add(new SplashScreenReactPackage());
packages.add(new CodePush("xxxxx", MainApplication.this, BuildConfig.DEBUG));
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
@Override
protected String getJSBundleFile() {
return CodePush.getJSBundleFile();
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
AndroidManifest.xml
:<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.app"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:largeHeap="true"
android:testOnly="false"
android:theme="@style/AppTheme"
>
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter android:label="filter_react_native">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="app" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<service android:name="io.invertase.firebase.messaging.RNFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseInstanceIdService">
<intent-filter>
<action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
</intent-filter>
</service>
<service android:name="io.invertase.firebase.messaging.RNFirebaseBackgroundMessagingService" />
<service android:name=".adyenReactNative.AdyenDropInService" android:permission="android.permission.BIND_JOB_SERVICE"/>
<meta-data
android:name="io.fabric.ApiKey"
android:value="xxxx" />
<meta-data
android:name="firebase_performance_collection_enabled"
android:value="true" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true"
tools:replace="android:authorities"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"
tools:replace="android:resource" />
</provider>
</application>
</manifest>
</p> </details>
<details><summary>Click To Expand</summary> <p>
react-native info
output:
<!-- Please run react-native info
on your terminal and paste the contents into the code block below -->
System:
OS: macOS 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Memory: 3.44 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.15.0 - ~/.nvm/versions/node/v11.15.0/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.7.0 - ~/.nvm/versions/node/v11.15.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 10.3/10G8 - /usr/bin/xcodebuild
npmPackages:
@react-native-community/cli: ^2.9.0 => 2.9.0
react: ^16.8.6 => 16.8.6
react-native: ^0.60.0 => 0.60.5
<!-- change [ ]
to [x]
to select an option(s) -->
react-native-firebase
version you're using that has this issue:
5.1.0
Firebase
module(s) you're using that has the issue:
firebase
TypeScript
?
Y
</p> </details>
<!-- Thanks for reading this far down ❤️ --> <!-- High quality, detailed issues are much easier to triage for maintainers -->
<!-- For bonus points, if you put a 🔥 (:fire:) emojii at the start of the issue title we'll know --> <!-- that you took the time to fill this out correctly, or, at least read this far -->
Think react-native-firebase
is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]
React Native Firebase
and Invertase
on Twitter for updates on the library.I think I found my ultimate error here.
In my package.json
file I had, at some point earlier, installed both the @react-native-firebase/app
and the react-native-firebase
packages.
It seems like the clever auto-importing/linking was bringing both these into the Android project (as it should) which was causing the duplicate class errors. I removed the @react-native-firebase/
packages and now most of my issues have been resolved. :)