Multiple dex files define Lcom/google/android/gms/internal/zzqf - react-native

I am getting following error while running the build command. However I am using only one version of google service.
:app:dexDebug
Unknown source file : UNEXPECTED TOP-LEVEL EXCEPTION:
Unknown source file : com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzqf;
Unknown source file : at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
Unknown source file : at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
Unknown source file : at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
Unknown source file : at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
Unknown source file : at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
Unknown source file : at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
Unknown source file : at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
Unknown source file : at com.android.dx.command.dexer.Main.run(Main.java:277)
Unknown source file : at com.android.dx.command.dexer.Main.main(Main.java:245)
Unknown source file : at com.android.dx.command.Main.main(Main.java:106)
build.gradle
dependencies {
compile(project(':react-native-google-signin')){
exclude group: "com.google.android.gms" // very important
}
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile 'com.google.android.gms:play-services-auth:9.2.1'
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':react-native-vector-icons')
compile "com.airbnb.android:react-native-maps:0.7.1"
compile 'com.google.android.gms:play-services-maps:9.2.1'
compile project(':react-native-image-picker')
compile project(':RNMaterialKit')
compile project(':react-native-fcm')
}

Changing node_modules is not the right approach, you can apply the dex in /android/app/build.gradle forcefully.
compile ('com.google.android.gms:play-services-auth:9.2.1'){
force=true
}
compile ('com.google.android.gms:play-services-maps:9.2.1'){
force=true
}
Do make sure that all your dependencies support 9.2.1

You are using play-services:9.2.1 make sure you have same play-service version in your entire project including node modules.
Look at the following screenshot. I have same play-service version in the entire project.
Solution: Apply the dex in /android/app/build.gradle forcefully.
compile ('com.google.android.gms:play-services-auth:9.2.1'){
force=true
}
compile ('com.google.android.gms:play-services-maps:9.2.1'){
force=true
}

Related

react-native link adds compile to gradle script, but compile support soon gone

Whenever I use react-native link, it adds the following to my app gradle file.
Image from Android Studio Gradle File
Then when I compile this, Android Studio tells me that "compile" is being deprecated and won't be supported after 2018. My question is, what would the correct replacement be for, for instance, react-native-ionicons?
The section of the gradle file in question is as follows.
dependencies {
compile project(':react-native-vector-icons')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.facebook.react:react-native:+'
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.squareup.okhttp3:okhttp:3.4.0-RC1'
implementation 'com.android.support.constraint:constraint-layout:1.0.0-alpha3'
testImplementation 'junit:junit:4.12'}
It was due to react-native link not having been updated but as of React-Native 0.58.3 the linking procedure has been updated so that compile and api have been replaced with implementation. Which you can see at this pull request
You could also just change compile to implementation in your grade file.
However you may find that some of the build.gradle files for the dependencies still use compile and api, unfortunately they only way to fix warnings from those is to make a pull request on the dependency changing compile and api to implementation

React Native command line 'processDebugGoogleServices' error

I am trying to build an app with below build.gradle file but there is always one error failed to create folder. I have checked many answers but no one helped me in this.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Failed to create folder: D:\App\android\app\build\generated\res\google-services\debug
my app/build.gradle file
dependencies {
compile project(':react-native-android-permissions')
compile project(':react-native-push-notification')
compile project(':react-native-fbsdk')
compile project(':react-native-google-signin')
compile project(':react-native-image-resizer')
compile project(':react-native-image-picker')
compile project(':react-native-fs')
compile project(':react-native-vector-icons')
compile project(':react-native-maps')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:25.0.0"
compile "com.facebook.react:react-native:+" // From node_modules
compile project(':RNPermissionsModule')
compile(project(":react-native-google-signin")) {
exclude group: "com.google.android.gms"
}
compile(project(':react-native-fbsdk')){
exclude(group: 'com.facebook.android', module: 'facebook-android-sdk')
}
compile "com.facebook.android:facebook-android-sdk:4.22.1"
compile "com.google.android.gms:play-services-maps:11.8.0"
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:25.0.1"
compile project(':react-native-push-notification')
compile ('com.google.android.gms:play-services-gcm:11.8.0') {
force = true;
}
}
apply plugin: 'com.google.gms.google-services'
Have you used google services plugin in classpath also?
If not please write in build.gradle located outside of the app folder
classpath 'com.google.gms:google-services:3.0.0'
I think this will help you ..!!
I faced the same problem and I solved this by uninstalling the app [yourapp.apk] from your device (e.g: your mobile device) and then run react-native run-android again and it worked like a charm.
But Why?
because you've already had the app with the same name installed on your device (mainly because of the reason that you've downloaded it from somewhere -- and now you want to run the test.app which has the same name, so that's why you've faced this error
do not hesitate to ask me any questions if it didn't work for you!

react-native Link - repeated invocations keep appending to configuration files [duplicate]

This question already has answers here:
react-native link causes duplicate imports in Android settings.gradle
(2 answers)
Closed 4 years ago.
React Native Link appears not to parse the previous changes to configurations files, and instead makes incremental, repetitive changes.
For instance, android/app/build.gradle starts with:
dependencies {
compile project(':react-native-linear-gradient')
compile project(':react-native-fcm')
compile project(':react-native-cookie')
}
After first invocation of react-native link
dependencies {
compile project(':react-native-vector-icons')
compile project(':react-native-linear-gradient')
compile project(':react-native-fcm')
compile project(':react-native-cookie')
compile project(':react-native-linear-gradient')
compile project(':react-native-fcm')
compile project(':react-native-cookie')
}
After second invocation...
dependencies {
compile project(':react-native-vector-icons')
compile project(':react-native-linear-gradient')
compile project(':react-native-fcm')
compile project(':react-native-cookie')
compile project(':react-native-vector-icons')
compile project(':react-native-linear-gradient')
compile project(':react-native-fcm')
compile project(':react-native-cookie')
compile project(':react-native-linear-gradient')
compile project(':react-native-fcm')
compile project(':react-native-cookie')
}
And so on..
Any good place to start my investigation?
Hey your answer is there : react-native link causes duplicate imports in Android settings.gradle
It is currently in PR and being tested.

How to install Evernote android-job on React Native?

I've created a repo in which the error can be easily reproducible:
https://github.com/yaronlevi/android_job_with_react_native
I am trying to install Evernote's library android-job for scheduling jobs in a React Native project (with Play Services also installed).
When I run the project I get an error in the Dex phase:
Multiple dex files define Landroid/support/v4/app/BundleUtil
Dex: Error converting bytecode to dex:
Cause: com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/BundleUtil;
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Landroid/support/v4/app/BundleUtil;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
It seems like several libraries are trying to fetch different versions of a support library.
What I did is just added android-job to the gradle file:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.evernote:android-job:1.2.2'
}
The exact steps I took can be seen in the repo link above. (You can clone it and run easily).
How can I solve the conflict that occurs regarding the support library.
Thanks in advance (-:

Errors with Tensorflow Cmake Build

I'm trying to build Tensorflow on Windows 7 x64 using the guide published here, however, when invoking MSBuild to build TensorFlow (step 4), I get a "Build FAILED" message followed by several errors.
The first:
CUSTOMBUILD : CMake error : CMake can not determine linker language for target: grpc [grpc.vcxproj]
CUSTOMBUILD : CMake error : CMake can not determine linker language for target: grpc_unsecure [grpc.vcxproj]
CUSTOMBUILD : CMake error : CMake can not determine linker language for target: cares [grpc.vcxproj]
does not make sense because within my grpc CMakelists.txt I have the following defined:
set(PACKAGE_NAME "grpc")
project(${PACKAGE_NAME} C CXX)
The other errors all involve source directories not containing a CMakelists.txt file:
CUSTOMBUILD : CMake error : The source directory "C:/tf-dev/local_repos/cub-1.6.4" does not appear to contain CMakeLists.txt. [cub.vcxproj]
which occurs for the following external projects:
cub
farmhash
fft2d
gemmlowp
gif
highwayhash
jpeg
lmdb
However, the Tensorflow build guide does not make any reference to creating additional CMakelists.txt for the externally added projects. Any idea where I might be going wrong? Thanks.