any ideas?
@simonhintersonnleitner you most likely have duplicate android libs, especially if you're using multiple modules that require firebase, modify your android/app/build.gradle dependencies section to explicitly compile a certain firebase version and then exclude from other project compiles, e.g here's what ours sort of looks like:
// ...
dependencies {
compile (project(':react-native-firebase')) {
// EXCLUDED:
exclude group: "com.google.android.gms"
exclude group: "com.google.firebase"
}
compile (project(':react-native-google-analytics-bridge')) {
exclude group: "com.google.android.gms"
}
compile (project(':react-native-push-notification')) {
exclude group: "com.google.android.gms"
exclude group: "me.leolin.ShortcutBadger"
}
compile (project(':react-native-appsflyer')) {
exclude group: "com.google.android.gms"
}
compile (project(':react-native-device-info')) {
exclude group: "com.google.android.gms"
}
compile (project(':RNAdMob')) {
exclude group: "com.google.android.gms"
}
compile (project(':react-native-fcm')) {
exclude group: "com.google.firebase"
exclude group: "me.leolin.ShortcutBadger"
}
compile 'com.google.android.gms:play-services-base:10.2.0'
compile 'com.google.android.gms:play-services-gcm:10.2.0'
compile 'com.google.android.gms:play-services-analytics:10.2.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.gms:play-services-identity:10.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.google.firebase:firebase-config:10.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.firebase:firebase-analytics:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-storage:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
compile ('com.google.android.gms:play-services-gcm:10.2.0') {
force = true;
}
compile fileTree(dir: "libs", include: ["*.jar"])
compile 'com.facebook.react:react-native:+' // From node_modules
}
// ...
Same applies to other google libs like com.google.android.gms as above
Im getting the same issue but with Expokit. If exclude group: "com.google.android.gms" then react-native-maps asks for it (Expokit has it included not extra install). The only way the app compiles is adding exclude group: "com.google.android.gms" but then the app crashes as Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.GoogleMapOptions".
react-native-firebase v.1.1.0
@andfk you should still have com.google.android.gms included from at least one of the libraries. Or remove it from them all and include it yourself. Post your build.gradle file if you want.
http://invertase.io/react-native-firebase/#/faqs?id=android-duplicate-dex-files-error-build-time-error This should help.
@Ehesp awesome. I have tested what you suggested and based on the above example I added the exclude groups correctly. It compiles correctly with v10.2.0 (like above example) but if I set v10.2.6 (the version included in the build.gradle of react-native-firebase) or even 11.0.0 (most recent) its not compiling with the following error:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties
File1: /Users/maxf/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.4.1/c7c4f9e35c2fd5900da24f9872e3971801f08ce0/okhttp-3.4.1.jar
File2: /Users/maxf/App/rnapp/android/app/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/10.2.6/jars/classes.jar
For now is okay as its compiling finally but I would like to know what this happens.
The dependencies part of my build.gradle with expokit is:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:multidex:1.0.0'
compile('host.exp.exponent:expoview:17.0.0@aar') {
exclude group: 'com.facebook.android', module: 'facebook-android-sdk'
exclude group: 'com.facebook.android', module: 'audience-network-sdk'
exclude group: 'io.nlopez.smartlocation', module: 'library'
exclude group: "com.google.android.gms"
transitive = true;
}
compile ('com.facebook.android:facebook-android-sdk:4.7.0') {
exclude module: 'bolts-android'
}
compile('com.facebook.android:audience-network-sdk:4.19.0') {
exclude module: 'play-services-ads'
}
compile('io.nlopez.smartlocation:library:3.2.11') {
transitive = false
}
dependencies {
compile (project(':react-native-firebase')){
exclude group: "com.google.android.gms"
exclude group: "com.google.firebase"
}
}
compile ("com.google.android.gms:play-services-base:10.2.0") {
force = true
}
compile "com.google.android.gms:play-services-maps:10.2.0"
compile 'com.google.android.gms:play-services-gcm:10.2.0'
compile 'com.google.android.gms:play-services-analytics:10.2.0'
compile 'com.google.android.gms:play-services-location:10.2.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.google.android.gms:play-services-identity:10.2.0'
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.google.firebase:firebase-ads:10.2.0'
compile 'com.google.firebase:firebase-config:10.2.0'
compile 'com.google.firebase:firebase-auth:10.2.0'
compile 'com.google.firebase:firebase-analytics:10.2.0'
compile 'com.google.firebase:firebase-database:10.2.0'
compile 'com.google.firebase:firebase-storage:10.2.0'
compile 'com.google.firebase:firebase-messaging:10.2.0'
compile 'com.google.firebase:firebase-crash:10.2.0'
}
PS: I think this error should be part of the react-native docs as it seems it could be something that may happen very often.
Many many thanks
I have a similar issue with duplicate files error on build:
:app:transformResourcesWithMergeJavaResForDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE
File1: <app>/android/app/build/intermediates/exploded-aar/com.google.firebase/firebase-firestore/11.8.0/jars/classes.jar
File2: ~/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.8.7/8b46f39c78476fb848c81a49fa807a9e9506dddd/jackson-core-2.8.7.jar
I'm wondering if I should fix by adding excludes like on https://github.com/VeeShostak/react-native-ai-chat-hybrid/issues/13#issuecomment-346915333 to fix?
EDIT: the excludes method does work, for these duplicate non-code files
Most helpful comment
@simonhintersonnleitner you most likely have duplicate android libs, especially if you're using multiple modules that require firebase, modify your
android/app/build.gradledependencies section to explicitly compile a certain firebase version and then exclude from other project compiles, e.g here's what ours sort of looks like:Same applies to other google libs like
com.google.android.gmsas above