Mobile App generation Cordova issues with 2.5.1 [Solved]

I had seen this issue while I was trying to solve my build issues and it did give helpful hints for me.
I think the solution suggested in the github issue is done in my project using the mobile-config.js — refer my first post in this message trail. And, I think, it is also linked to cordova:@havesource/cordova-plugin-push as this plugin is the core for push and firebase used within activitree:push

1 Like

nothing to do… I follow all steps but at the end is always:

BUILD SUCCESSFUL in 424ms
1 actionable task: 1 executed
%% Subproject Path: CordovaLib                
Subproject Path: CordovaLibEmulator          -
%% Subproject Path: app                       
Subproject Path: appndroid Emulator          -
%% Gradle Distribution URL: https://services.gradle.org/distributions/gradle-7.1.1-all.zip

> Configure project :app
Adding classpath: com.google.gms:google-services:4.3.10
Warning: The 'kotlin-android-extensions' Gradle plugin is deprecated. Please use this migration guide (https://goo.gle/kotlin-android-extensions-deprecation) to start working with View Binding (https://developer.android.com/topic/libraries/view-binding) and the 'kotlin-parcelize' plugin.
WARNING:: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed in version 7.0 of the Android Gradle plugin.
For more information, see http://d.android.com/r/tools/update-dependency-configurations.html.

FAILURE: Build failed with an exception.

* Where:
Build file '/home/user/Sviluppo/meteor/mp/.meteor/local/cordova-build/platforms/android/app/build.gradle' line: 357

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.google.gms.google-services'.
   > Cannot add extension with name 'googleServices', as there is an extension already registered with that name.

App is builded but there is an error in google services configuration…

I am sure working with meteor cordovoa you have realised that final error thrown during cordova build can be misleading.

I got a similar error and upgrading gradle fixed it.

for me I did not have to change google configuration file

good luck

I’m on gradle 7.3.3, is the last release…

@paulishca do you have some advice to give me ?
Have you see this issue ?
I’m using activitree:push from many months and works very well but now I can’t upgrade Meteor for this problems.

Hi @davideonmeteor, my advice is to troubleshoot this problem and if activitree:push needs an update, to submit a PR. The package requires a push plugin that is no longer supported however is not yet obsolete. That is the only Cordova specific component. I think your problem requires a Gradle/Android solution.

In your gradle file you seem to use the old ‘compile’ syntax instead of ‘implementations’, like so:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    // SUB-PROJECT DEPENDENCIES START
    implementation project(path: ":CordovaLib")
    implementation "com.squareup.okhttp3:okhttp:3.11.0"
    implementation "com.android.support:appcompat-v7:28.0.0"
    implementation "com.android.support:support-v13:28.0.0"
    implementation "me.leolin:ShortcutBadger:1.1.22"
    implementation "com.google.firebase:firebase-messaging:17.1.0"
    implementation "com.facebook.android:facebook-android-sdk:4.36.0"
    implementation "com.google.android.gms:play-services-auth:16.0.0"
    implementation "com.google.android.gms:play-services-identity:15.0.1"
    // SUB-PROJECT DEPENDENCIES END
}

You may have a look at the Android section in the documentation: meteor-push/README.md at master · activitree/meteor-push · GitHub

thanx.
In my gradle file there is:

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    implementation "androidx.appcompat:appcompat:${cordovaConfig.ANDROIDX_APP_COMPAT_VERSION}"

    if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${cordovaConfig.KOTLIN_VERSION}"
    }

    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: ":CordovaLib"))
    implementation "androidx.legacy:legacy-support-v4:1.0.0"
    implementation "androidx.webkit:webkit:1.3.0"
    implementation "com.squareup.okhttp3:okhttp:3.9.1"
    implementation "androidx.appcompat:appcompat:1.2.0"
    implementation "androidx.legacy:legacy-support-v13:1.0.0"
    implementation "me.leolin:ShortcutBadger:1.1.17@aar"
    implementation "com.google.firebase:firebase-messaging:17.0.+"
    implementation "androidx.core:core:1.6.+"
    implementation "me.leolin:ShortcutBadger:1.1.22@aar"
    implementation "com.google.firebase:firebase-messaging:18.+"
    // SUB-PROJECT DEPENDENCIES END
}

Hey there, I’m still struggeling with this and I’m really happy that I found this thread. I guess adding App.setPreference("GradlePluginGoogleServicesEnabled", true); App.setPreference("GradlePluginGoogleServicesVersion", "4.3.10");
is key.

phonegap-plugin-push, which is used in @paulishca s package relies on GitHub - chemerisuk/cordova-support-google-services: DEPRECATED. Cordova plugin to add google services support, and the latter is deprecated; could it be that this causes @davideonmeteor s problem? My build now fails with the same msg, that “there is an extension already registered with that name…”

Ok I finally got this working using phonegap-plugin-push, meteor 2.5.6 and activitree:push by @paulishca , though I find it a bit hacky:

1.) As mentioned above, add App.setPreference("GradlePluginGoogleServicesEnabled", true); App.setPreference("GradlePluginGoogleServicesVersion", "4.3.10"); to mobile-config.js

2.) After first build run for platform android, add google-services.json and in cordova-support-google-services gradle file, remove or comment out the line apply plugin: com.google.gms.googleservices.GoogleServicesPlugin. This is already done in the main gradle file by mobile-config.js and causes the error mentioned by @davideonmeteor

3.) Building now is working fine and push is sent to android devices.

@paulishca can we merge this somehow into your package?

@paulishca what do you think about it ?
My app unfurtunally is blocked to update Meteor version, maybe is very important.
Thanx

1 Like

Hi @davideonmeteor, please detail “it”.

About @bratelefant post, previuos than mine.
Is possible ?

Hi @bratelefant and @davideonmeteor,

this Push package does not contain/store gradle files or configurations. Those files are being generated by the Android tools based on the plugins content of your project. At times, actually very often, developers encounter version conflicts of different google plugins and there are strategies found in Google/Android that deal with these problems.
While I also believe these could be hinted to in this package, there is no particular place of the project that may accommodate gradle files…because they are being generated by the android build process. You first need to generate, see what the problems may be and then correct those problems. This is what I understand from this matter and I am open to any suggestions if you think this can be integrated in the package.

That’s what I‘m doing right now via cordova-build-override.

1 Like

If you get a solutions would a great idea to adding in @paulishca repo

I encountered this problem with a duplicate google-services being included in my Gradle build.

I’ve created a Cordova plugin that essentially automates @bratelefant 's hack.

You can try it:

meteor add cordova:cordova-plugin-remove-googleservices@0.1.1

It looks through your android project.properties file and removes anything where the value matches cordova-support-google-services, and then reindexes all the remaining cordova.gradle.include entries in the same properties file. This prevents Gradle from including cordova-support-google-services, which would otherwise have included the line @bratelefant mentions above.

The source repository is here.

( @davideonmeteor )

3 Likes

Great to hear that ! I will try it soon !

1 Like

Sounds cool, will also give it a shot

1 Like

Ok just made it work. However, I don’t like what we had to do to make it work :wink:

We did install :
meteor add cordova:cordova-plugin-remove-googleservices@0.1.1

AND add these to the mobile-config.js
App.setPreference(“GradlePluginGoogleServicesEnabled”, true);
App.setPreference(“GradlePluginGoogleServicesVersion”, “4.3.10”);

Without one or the other… it did not build!!

Thanks a lot for your help!!

Has anyone fixed the error yet? :smiling_face_with_tear: