0

When trying to install Pushnotifications for Android in a React Native project I get the following error during building

Could not find com.google.android.gms:play-services-analytics:15.0.1.

I cannot find the place where I would require play-services-analytics. Anyone a clue how I could solve this issue?

Pimmesz
  • 335
  • 2
  • 8
  • 29
  • Dependencies in an android project are defined in your app/build.gradle file. Make sure this dependency is listed in this file. Which notification library do you use exactly ? Sometimes, automatic linking doesn't work well... – Vinzzz Dec 06 '18 at 13:29
  • Thank you for your response! I am currently using [zo0r/react-native-push-notification](https://github.com/zo0r/react-native-push-notification). Directly adding 'com.google.android.gms:play-services-analytics:15.0.1' to my `build.gradle` file does not seem to work so I guess the syntax is a bitt different? Not much too find in the Firebase setup docs... – Pimmesz Dec 06 '18 at 13:49
  • You shouldn't add it yourself (I saw no mention of this lib in their repository) , it's probably a dependency from one of your modules - react-native-push-notification has its own build.gradle, and so on... Look at your app dependencies and see where this lib comes from. Your problem might be caused by a dependency incompatibility between 2 modules... (https://stackoverflow.com/questions/39008887/how-do-i-show-dependencies-tree-in-android-studio) – Vinzzz Dec 06 '18 at 14:30

1 Answers1

1

I had the same issue. Sometimes, the dependency version used by a package is no longer the recommended minimum that's been pushed by Google. To fix, locate the build.gradle file for the package that is giving you the error (in this case, it should be react-native-push-notification) and change locate the line that contains play-services-analytics under the dependencies, then change the version number to the recommended minimum version listed here. For play-services-analytics, it should be 16.0.5. Here's how it should look like afterward

implementation "com.google.android.gms:play-services-analytics:${safeExtGet('googlePlayServicesVersion', '16.0.5')}"

By far, the easiest way I've found to debug these package error is to get Android Studio. When you run the App from there, it'll error out on any dependency error and open up the gradle file for you, then you just have to fix it.

Nerdragen
  • 2,976
  • 2
  • 11
  • 22