Mobile App generation Cordova issues with 2.5.1 [Solved]

If anybody is facing issues running android app after migrating to 2.5.1, some hints that helped me

make sure the cordova-plugin-meteor-webapp is at the latest version in cordova-plugins

cordova-plugin-meteor-webapp@2.0.0

you may have to add androidx adapter to cordova-plugins be compatible

cordova-plugin-androidx-adapter@1.1.3

if you are using google services, specially push, you may need to add the following lines to mobile-config.js

App.setPreference("GradlePluginGoogleServicesEnabled", true);
App.setPreference("GradlePluginGoogleServicesVersion", "4.3.10");

for local development and testing you may need to add the following lines to mobile-config.js

App.appendToConfig(`
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
        <application android:usesCleartextTraffic="true"></application>
    </edit-config>
`);

to remove compile time warnings from gradle you may need to upgrade gradle on your local computerā€¦on Ubuntu I have moved to 7.3.2

last but not least, if you are still facing problems, some times deleting cordova-build folder in .meteor/local and regenerating does help.

Hope this helps someone.

2 Likes

Thank you for shared this.
I have trouble with latest Meteor version to build Android app and I tried this configuration but still no build, error is:
> Cannot add extension with name 'googleServices', as there is an extension already registered with that name.
Do you have some advice ?

Please make sure you do not another plugin (like I had cordova-play-services-version-adapter) adding googleServices which may cause problems. In earlier version this - cordova-play-services-version-adapter-- adapter plugin was used to resolve conflict for googleServices

I donā€™t see any play services plugin in my plugin.
This is my meteor plugins:

accounts-base@2.1.0
accounts-password@2.1.0
accounts-ui@1.4.1
accounts-ui-unstyled@1.5.1
activitree:push@2.0.10
alanning:roles@1.3.0
allow-deny@1.1.0
autoupdate@1.7.0
babel-compiler@7.7.0
babel-runtime@1.5.0
base64@1.0.12
binary-heap@1.0.11
blaze@2.5.0
blaze-tools@1.1.2
boilerplate-generator@1.7.1
caching-compiler@1.2.2
caching-html-compiler@1.2.1
callback-hook@1.4.0
check@1.3.1
cultofcoders:redis-oplog@2.0.5
ddp@1.4.0
ddp-client@2.5.0
ddp-common@1.4.0
ddp-rate-limiter@1.1.0
ddp-server@2.5.0
diff-sequence@1.1.1
disable-oplog@1.0.7
dynamic-import@0.7.1
ecmascript@0.15.3
ecmascript-runtime@0.8.0
ecmascript-runtime-client@0.12.0
ecmascript-runtime-server@0.11.0
ejson@1.1.1
email@2.2.0
es5-shim@4.8.0
fetch@0.1.1
geojson-utils@1.0.10
harrison:papa-parse@1.1.7
hot-code-push@1.0.4
html-tools@1.1.2
htmljs@1.1.1
http@1.4.4
hybrid:device@1.0.1
id-map@1.1.1
inter-process-messaging@0.1.1
jquery@1.11.11
launch-screen@1.3.0
less@4.0.0
localstorage@1.2.0
logging@1.3.1
mdg:validated-method@1.2.0
meteor@1.10.0
meteor-base@1.5.1
minifier-css@1.6.0
minifier-js@2.7.1
minimongo@1.7.0
mizzao:timesync@0.5.2
mizzao:user-status@1.0.1
mobile-experience@1.1.0
mobile-status-bar@1.1.0
modern-browsers@0.1.6
modules@0.17.0
modules-runtime@0.12.0
momentjs:moment@2.29.1
mongo@1.13.0
mongo-decimal@0.1.2
mongo-dev-server@1.1.0
mongo-id@1.0.8
npm-mongo@3.9.1
observe-sequence@1.0.19
ordered-dict@1.1.0
ostrio:cookies@2.7.0
ostrio:files@2.0.1
ostrio:templatehelpers@2.2.2
promise@0.12.0
random@1.2.0
rate-limit@1.0.9
react-fast-refresh@0.1.1
react-meteor-data@2.3.3
reactive-dict@1.3.0
reactive-var@1.0.11
reload@1.3.1
retry@1.1.0
routepolicy@1.1.1
rzymek:moment-locale-it@2.14.1
service-configuration@1.2.0
session@1.2.0
sha@1.0.9
shell-server@0.5.0
socket-stream-client@0.4.0
spacebars@1.2.0
spacebars-compiler@1.3.0
standard-minifier-css@1.7.4
standard-minifier-js@2.7.1
static-html@1.3.2
templating@1.4.1
templating-compiler@1.4.1
templating-runtime@1.5.0
templating-tools@1.2.1
tracker@1.2.0
typescript@4.3.5
underscore@1.0.10
url@1.3.2
webapp@1.12.0
webapp-hashing@1.1.0

Difficult to figure outā€¦ I will share my cordova and packages.json

My cordova-plugins file

@havesource/cordova-plugin-push@3.0.0
cordova-plugin-android-permissions@1.1.2
cordova-plugin-appinfo@2.1.2
cordova-plugin-calendar@5.1.5
cordova-plugin-camera@6.0.0
cordova-plugin-device@2.0.3
cordova-plugin-file@6.0.2
cordova-plugin-geolocation@4.1.0
cordova-plugin-inappbrowser@5.0.0
cordova-plugin-local-notification@0.9.0-beta.3
cordova-plugin-media-capture@3.0.3
cordova-plugin-meteor-webapp@2.0.0
cordova-plugin-network-information@3.0.0
cordova-plugin-splashscreen@6.0.0
cordova-plugin-androidx-adapter@1.1.3
phonegap-nfc-isodep@https://github.com/as-eldlc/phonegap-nfc-isodep.git#d34fc1943832c620aa1e1358211069128a587fd7
cordova-plugin-file-transfer@https://github.com/apache/cordova-plugin-file-transfer.git#5c29f9a0e1b0cddb9c0cdf7b79139ae8e523e5c1

My package.json file for cordova specific parts

"cordova-android": "^10.1.1",
    "cordova-common": "^4.0.2",
    "cordova-custom-config": "^5.1.0",
    "cordova-plugin-androidx-adapter": "^1.1.3",
    "cordova-plugin-local-notification": "^0.9.0-beta.3",type or paste code here

hope this helps (in your list you have not mentioned the versions, I think cordova plugins need to be of the right version. I feel only two of your plugins need to be checked ā€“ cordova:@havesource/cordova-plugin-push which I suspect is used by activitree:push ( I use raix:push)

Many thanx for your time and sorry for plugin list without versionā€¦ :frowning: I updated now.
Yes, I use activitree:push for several months and it works very good, and @paulishca aided me many time, heā€™s very helpfull.
Now I found this issue in github, seems to be clear now:

I hope it is solved in the futureā€¦
One thingā€¦ in my package.json there isā€™nt your plugin but only:

    "cordova-plugin-crosswalk-webview": "^2.4.0",
    "cordova-plugin-statusbar": "^2.4.3",

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