• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Android GooglePlayServicesExtension & Firebase - GooglePushNotificationsExtension Collision (Duplicate Resources)

I get a build error after I've added both GooglePlayServicesExtension & GooglePushNotificationsExtension

_________________________________________________________________________________________________________________________________________________________________________________

First this:

* What went wrong:
Could not determine the dependencies of task ':com.:******************:compileReleaseJavaWithJavac'.
> In project 'com.:******************' a resolved Google Play services library dependency depends on another
at an exact version (e.g. "[17.0.4]", but isn't being resolved to that version. Behavior exhibited by the library will
be unknown.

Dependency failing: com.google.firebase:firebase-messaging:17.3.4 -> com.google.firebase:firebase-iid@[17.0.4], but fire
base-iid version was 20.1.5.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
ifact with the issue.
-- Project 'com.:******************' depends onto com.google.firebase:firebase-messaging@{strictly 17.3.4}
-- Project 'com.:******************' depends onto com.google.firebase:firebase-analytics@{strictly 17.4.1}
-- Project 'com.:******************' depends onto com.google.android.gms:play-services-measurement-api@{st
rictly 17.4.1}
-- Project 'com.:******************' depends onto com.google.firebase:firebase-iid@{strictly 20.1.5}
-- Project 'com.:******************' depends onto com.google.firebase:firebase-analytics@17.4.1
-- Project 'com.:******************' depends onto com.google.firebase:firebase-messaging@17.3.4

For extended debugging info execute Gradle from the command line with ./gradlew --info :com.daniel_westberg.fett_najsa_o
lspel:assembleDebug to see the dependency paths to the artifact. This error message came from the google-services Gradle
plugin, report issues at https://github.com/google/play-services-plugins and disable by adding "googleServices { disabl
eVersionCheck = false }" to your build.gradle file.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

_________________________________________________________________________________________________________________________________________________________________________________

Then after adding googleServices { disableVersionCheck = false } in the bottom of my build.gradle file I get this error:

* What went wrong:
Execution failed for task ':com.******************:mergeDebugResources'.
> [string/google_app_id] W:\com.******************\src\main\res\values\gfn_values.xml [string/google_app_id] W:\com.******************\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
[string/default_web_client_id] W:\com.******************\src\main\res\values\gfn_values.xml [string/default_web_client_id] W:\com.******************\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
[string/firebase_database_url] W:\com.******************\src\main\res\values\gfn_values.xml [string/firebase_database_url] W:\com.******************\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
[string/google_api_key] W:\com.******************\src\main\res\values\gfn_values.xml [string/google_api_key] W:\com.******************\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources
[string/project_id] W:\com.******************\src\main\res\values\gfn_values.xml [string/project_id] W:\com.******************\build\generated\res\google-services\debug\values\values.xml: Error: Duplicate resources

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1.1/userguide/command_line_interface.html#sec:command_line_warnings

_________________________________________________________________________________________________________________________________________________________________________________

(com.****************** = com.my_name.my_app_name)

After some "research" I found some plugins that seem to help with this exact issue: https://github.com/dpa99c/cordova-android-firebase-gradle-release + https://github.com/dpa99c/cordova-android-play-services-gradle-release
But I have no idea if I have any use of it/if I can use it with GMS2. I'm pretty much a noob when it comes to publishing apps.
This is my first ever app to publish, so... any help would be appreciated!
 

chamaeleon

Member
@Daniel Westberg

For whatever it's worth, I just installed Android Studio 4 on the computer I use currently, and added Android SDK 29 and 30, and NDK 21 (not exactly the recommended versions, but newer, going against my recommendation of using exactly the versions mentioned in the Required SDKs documentation). I created a blank project and imported the two Google extensions (Play Services and Notification), where I excluded the objInit and objButton objects from being imported from the notification extension because they exist in the play services extension already.

With build tools = 28.0.3, support library = 29.0.0, target sdk = 29, minimum sdk = 16, and compile sdk = 29, I encountered none of the above errors, and ended up with an APK (which I have not attempted to use in any way..) So, the question is, what did you do differently than I to get the error?
 
@Daniel Westberg

For whatever it's worth, I just installed Android Studio 4 on the computer I use currently, and added Android SDK 29 and 30, and NDK 21 (not exactly the recommended versions, but newer, going against my recommendation of using exactly the versions mentioned in the Required SDKs documentation). I created a blank project and imported the two Google extensions (Play Services and Notification), where I excluded the objInit and objButton objects from being imported from the notification extension because they exist in the play services extension already.

With build tools = 28.0.3, support library = 29.0.0, target sdk = 29, minimum sdk = 16, and compile sdk = 29, I encountered none of the above errors, and ended up with an APK (which I have not attempted to use in any way..) So, the question is, what did you do differently than I to get the error?
I followed this guide first:

I updated the gfn_values.xlm
<project folder>\extensions\GooglePushNotificationsExtension\AndroidSource\res\values\gfn_values.xml
accordingly,

" Once you've located the file, open it and fill in the values shown below with values from the following elements in the google-services.json file that you downloaded earlier:

  • google_app_id: client > client_info > mobilesdk_app_id
  • default_web_client_id: client > oauth_client > client_id
  • firebase_database_url: project_info > firebase_url
  • google_api_key: client > api_key > current_key
  • project_id: project_info > project_id "

I don't remember excluding any files... I have now removed the GooglePushNotificationsExtension and trying to follow this guide instead:

It's a little confusing, but I think cloud messaging and push notifications are the same thing... the guides are very different from each other.
If I'm correct, I can use all of the Google Services (Analytics, Push Notifications/Cloud Messaging, In-app messaging etc.) using only the GooglePlayServicesExtension and by implementing those different services by adding some code to the /$ProjectFiles - build.gradle:

At top:
apply plugin: 'com.google.gms.google-services'

dependencies {
implementation 'com.google.firebase:firebase-inappmessaging:19.0.7'
implementation 'com.google.firebase:firebase-inappmessaging-display:19.0.7'
implementation 'com.google.firebase:firebase-analytics:17.4.3'
implementation 'com.google.firebase:firebase-messaging:20.2.1'
...

and to the /$RootFiles - build.gradle:

buildscript {
repositories {
google() // Google's Maven repository //<----
...

dependencies {
classpath 'com.google.gms:google-services:4.3.3' //<----
...

allprojects {
repositories {
google() // Google's Maven repository //<----
...

But some things make no sense to me, like this example:

At Step 2: Declare the com.google.firebase.analytics.FirebaseAnalytics object at the top of your activity:
Been trying to figure out what I'm supposed to do here... I don't have a file that's called MainActivity.java - the closest I've come to find a similar file is C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2.2.5.378\android\runner\ProjectFiles\src\main\java\com\yoyogames\runner (RunnerJNILib.java) if that's where I'm supposed to add the code, I still don't know where to put it.

EDIT: I have the google-services.json file in: C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2.2.5.378\android\runner\ProjectFiles
EDIT: Build tools: 29.0.2, Support library: 29.0.0, Target SDK: 29, Minimum SDK: 16, Compile SDK: 29.
 
Last edited:

chamaeleon

Member
It's a little confusing, but I think cloud messaging and push notifications are the same thing... the guides are very different from each other.
If I'm correct, I can use all of the Google Services (Analytics, Push Notifications/Cloud Messaging, In-app messaging etc.) using only the GooglePlayServicesExtension and by implementing those different services by adding some code to the /$ProjectFiles - build.gradle:
GooglePushNotificationsExtension is the only one that refers to the Firebase API. If you don't include it you'll need to know Java programming, Android development, and the Firebase API and implement essentially the same thing from scratch yourself.
At Step 2: Declare the com.google.firebase.analytics.FirebaseAnalytics object at the top of your activity:
Been trying to figure out what I'm supposed to do here... I don't have a file that's called MainActivity.java - the closest I've come to find a similar file is C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-2.2.5.378\android\runner\ProjectFiles\src\main\java\com\yoyogames\runner (RunnerJNILib.java) if that's where I'm supposed to add the code, I still don't know where to put it.
I think you have a much better chance getting it working by using the existing extensions. You just need to figure out what is wrong with your current development system setup (GMS, Android, Android SDKs, Java installations, etc., that is) Modifying the runner code instead of relying on an extension when possible sounds like a recipe for disaster.

The google-services.json file has no place in your build as you're only using it to get some data to put in a file that is included with the push notification extension.
 
GooglePushNotificationsExtension is the only one that refers to the Firebase API. If you don't include it you'll need to know Java programming, Android development, and the Firebase API and implement essentially the same thing from scratch yourself.

I think you have a much better chance getting it working by using the existing extensions. You just need to figure out what is wrong with your current development system setup (GMS, Android, Android SDKs, Java installations, etc., that is) Modifying the runner code instead of relying on an extension when possible sounds like a recipe for disaster.

The google-services.json file has no place in your build as you're only using it to get some data to put in a file that is included with the push notification extension.
After following this [image], I managed to get Analytics working (had to add google-services.json to $ProjectFiles). I use GooglePlayServicesExtensions for Cloud Saving. If I add GooglePushNotificationsExtensions and follow the guide by YoYoGames, where I use the info taken from google-services.json, I get the duplicate error.

Are you saying I shouldn't add google-services.json as suggested in the image attached? Should I use an extension for Analytics too and delete the gradle code I've added? The guide by YoYoGames tells me to download google-services.json, but nothing about following the instructions by analytics.google.com ... I'm starting to realise things as I write this... lol. I've been overwhelmed by all those things and started digging too deep. It starts to make sense to me now, at least I hope so... I've been following too many instructions at the same time. I hope I can start over and get it to work - Will look for seperate extension for each thing I want to add and delete the java code I've been messing around with... I guess this is what happens when a noob is taking over a programmers job :)

I hope I don't need to add the info from google-services.json into several extensions. This might cause another duplicate error? Feel free to stop me if you see any errors in my thought process! 🤪 Thanks mate!
 

Attachments

Top