Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failed because of "ParseElementtreeSync is not a constructor" - cordova-common v4.1.0 #220

Open
IagoSRL opened this issue Feb 21, 2023 · 0 comments

Comments

@IagoSRL
Copy link

IagoSRL commented Feb 21, 2023

Bug Report

Error at compilation because ParseElementtreeSync is not a constructor.

That function is an alias for the utility parseElementtreeSync from cordova-common//src/util/xml-helpers.

Is called as a constructor here.

Proposed solution

Removing the keyword new fixes the problem. Additionally, the function could get imported with the original name (initial lowercase) to avoid confusions too.

I don't know why this utility was being used that way. I checked the module history back to it's origin at 2015 and was a normal function (not a constructor), but maybe that came from a refactor at another module implemented differently; anyway, it's a long way is not a constructor so I think the proposed change should be compatible with any recent and supported cordova/cordova-android version, or Am I missing something?

Expected Behaviour

Compile without errors

Actual Behaviour

Doesn't compile

Reproduce Scenario (including but not limited to)

Modern Cordova app.

Steps to Reproduce

Create Cordova APP, add plugin, compile.

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Tarket SDK 31 / Android 12.

And for Cordova

"cordova": "^11.0.0",
"cordova-android": "^9.1.0",

Internally, uses cordova-common version 4.1.0. Per their commit log, a refactor on that module causes that the function cannot be call as a constructor (using method notation on a plain object rather than assigning a function as property). Per the implementation of that function, now and on previous versions, is not needed at all call it as a constructor (I don't know it that's was different at some point in the past).

NodeJS v14.17.0 (the V8 engine is responsible for limiting the way the function is executed, so the source error message comes from it).

(Android) Device Vendor (e.g. Samsung, HTC, Sony...)

N/A

cordova info Printout

Cordova Packages:

    cli: 11.0.0
        common: 4.1.0
        create: 4.0.0
        lib: 11.0.0
            common: 4.1.0
            fetch: 3.1.0
            serve: 4.0.0

Project Installed Platforms:

    android: 9.1.0

Project Installed Plugins:

    @havesource/cordova-plugin-push: 4.0.0-dev.0
    cordova-android-firebase-gradle-release: 4.0.0
    cordova-android-play-services-gradle-release: 4.0.0
    cordova-android-support-gradle-release: 3.0.1
    cordova-plugin-androidx-adapter: 1.1.3
    cordova-plugin-camera: 5.0.1
    cordova-plugin-customurlscheme: 5.0.2
    cordova-plugin-device: 2.0.3
    cordova-plugin-file-transfer: 1.7.1
    cordova-plugin-file: 6.0.2
    cordova-plugin-ionic-keyboard: 2.2.0
    cordova-plugin-splashscreen: 6.0.0
    cordova-plugin-statusbar: 2.4.3
    cordova-plugin-whitelist: 1.3.4
    cordova-plugin-wifi-manager: 0.3.0
    cordova-plugin-x-socialsharing: 6.0.3
    es6-promise-plugin: 4.2.2

Environment:

    OS: Ubuntu 20.04.2 LTS (linux 5.15.79.1-microsoft-standard-WSL2) x64
    Node: v14.17.0
    npm: 6.14.13

android Environment:

    android:
Available Android targets:==============] 100% Fetch remote repository...
----------
id: 1 or "android-25"
     Name: Android API 25
     Type: Platform
     API level: 25
     Revision: 3
----------
id: 2 or "android-26"
     Name: Android API 26
     Type: Platform
     API level: 26
     Revision: 2
----------
id: 3 or "android-27"
     Name: Android API 27
     Type: Platform
     API level: 27
     Revision: 3
----------
id: 4 or "android-28"
     Name: Android API 28
     Type: Platform
     API level: 28
     Revision: 6
----------
id: 5 or "android-29"
     Name: Android API 29
     Type: Platform
     API level: 29
     Revision: 5
----------
id: 6 or "android-30"
     Name: Android API 30
     Type: Platform
     API level: 30
     Revision: 3


Project Setting Files:

    config.xml:
<?xml version='1.0' encoding='utf-8'?>
<widget
    xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"
    id="com.sample.app"
    version="2.0.2"
    defaultlocale = "es-ES"
    xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
    >
    <name>Sample<name>
    <description>
        Sample
    </description>
    <author email="[email protected]" href="https://me.com">
        ME
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <allow-navigation href="http://localhost:8080/*"/>
    <feature name="http://api.phonegap.com/1.0/device" />
    <preference name="permissions" value="none"/>
    <preference name="target-device"              value="universal" />      <!-- all: possible values handset, tablet, or universal -->
    <preference name="fullscreen"                 value="false" />           <!-- all: hides the status bar at the top of the screen -->
    <preference name="FadeSplashScreen"           value="true" />
    <preference name="FadeSplashScreenDuration"   value="500" />
    <preference name="ShowSplashScreenSpinner"    value="false"/>
    <preference name="AutoHideSplashScreen"       value="false" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <platform name="android">
        <preference name="android-compileSdkVersion"  value="31" />
        <preference name="android-targetSdkVersion"   value="31" />
        <preference name="android-installLocation"    value="auto" />     
        <preference name="AndroidXEnabled" value="true" />
        <preference name="AndroidPersistentFileLocation" value="Internal" />
        <resource-file src="res/google-services.json" target="app/google-services.json" />
        <edit-config file="app/src/main/AndroidManifest.xml" target="/manifest/application/activity[@android:name='MainActivity']" mode="merge">
            <activity android:exported="true"/>
        </edit-config>
    </platform>
    <platform name="android">
        <icon background="res/icon/android/icon-36-ldpi.png"     foreground="res/icon/android/icon-36-ldpi.png"     src="res/icon/android/icon-36-ldpi.png"   
   density="ldpi" />
        <icon background="res/icon/android/icon-48-mdpi.png"     foreground="res/icon/android/icon-48-mdpi.png"     src="res/icon/android/icon-48-mdpi.png"   
   density="mdpi" />
        <icon background="res/icon/android/icon-72-hdpi.png"     foreground="res/icon/android/icon-72-hdpi.png"     src="res/icon/android/icon-72-hdpi.png"   
   density="hdpi" />
        <icon background="res/icon/android/icon-96-xhdpi.png"    foreground="res/icon/android/icon-96-xhdpi.png"    src="res/icon/android/icon-96-xhdpi.png"  
   density="xhdpi" />
        <icon background="res/icon/android/icon-144-xxhdpi.png"  foreground="res/icon/android/icon-144-xxhdpi.png"  src="res/icon/android/icon-144-xxhdpi.png"   density="xxhdpi" />
        <icon background="res/icon/android/icon-192-xxxhdpi.png" foreground="res/icon/android/icon-192-xxxhdpi.png" src="res/icon/android/icon-192-xxxhdpi.png"  density="xxxhdpi" />

        <splash src="res/screen/android/screen-ldpi-portrait.png"   density="port-ldpi" />
        <splash src="res/screen/android/screen-mdpi-portrait.png"   density="port-mdpi" />
        <splash src="res/screen/android/screen-hdpi-portrait.png"   density="port-hdpi" />
        <splash src="res/screen/android/screen-xhdpi-portrait.png"  density="port-xhdpi" />
        <splash src="res/screen/android/screen-ldpi-landscape.png"  density="land-ldpi" />
        <splash src="res/screen/android/screen-mdpi-landscape.png"  density="land-mdpi" />
        <splash src="res/screen/android/screen-hdpi-landscape.png"  density="land-hdpi" />
        <splash src="res/screen/android/screen-xhdpi-landscape.png" density="land-xhdpi" />
    </platform>
</widget>

    package.json:
--- Start of Cordova JSON Snippet ---
{
  "platforms": [
    "android"
  ],
  "plugins": {
    "cordova-plugin-x-socialsharing": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+",
      "ANDROID_SUPPORT_V7_VERSION": "27.+"
    },
    "cordova-android-firebase-gradle-release": {
      "FIREBASE-CORE": "17.0.0",
      "FIREBASE-ADS": "18.0.0",
      "FIREBASE-ANALYTICS": "17.0.0",
      "FIREBASE-APPINDEXING": "19.0.0",
      "FIREBASE-AUTH": "18.0.0",
      "FIREBASE-FIRESTORE": "20.0.0",
      "FIREBASE-FUNCTIONS": "18.0.0",
      "FIREBASE-MESSAGING": "19.0.0",
      "FIREBASE-STORAGE": "18.0.0",
      "FIREBASE-CRASH": "16.2.1",
      "CRASHLYTICS": "2.10.1",
      "FIREBASE-DYNAMIC-LINKS": "18.0.0",
      "FIREBASE-INVITES": "17.0.0",
      "FIREBASE-INAPPMESSAGING": "18.0.1",
      "FIREBASE-INAPPMESSAGING-DISPLAY": "18.0.1",
      "FIREBASE-ML-VISION": "21.0.0",
      "FIREBASE-ML-VISION-IMAGE-LABEL-MODEL": "18.0.0",
      "FIREBASE-ML-VISION-FACE-MODEL": "18.0.0",
      "FIREBASE-ML-VISION-OBJECT-DETECTION-MODEL": "17.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-LANGUAGE-ID-MODEL": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-TRANSLATE-MODEL": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-SMART-REPLY-MODEL": "20.0.0",
      "FIREBASE-ML-MODEL-INTERPRETER": "20.0.0",
      "FIREBASE-ML-VISION-AUTOML": "17.0.0",
      "FIREBASE-PERF": "18.0.0",
      "FIREBASE-DATABASE": "18.0.0",
      "FIREBASE-CONFIG": "18.0.0"
    },
    "cordova-android-play-services-gradle-release": {
      "FIREBASE-CORE": "17.0.0",
      "FIREBASE-ADS": "18.0.0",
      "FIREBASE-ANALYTICS": "17.0.0",
      "FIREBASE-APPINDEXING": "19.0.0",
      "FIREBASE-AUTH": "18.0.0",
      "FIREBASE-FIRESTORE": "20.0.0",
      "FIREBASE-FUNCTIONS": "18.0.0",
      "FIREBASE-MESSAGING": "19.0.0",
      "FIREBASE-STORAGE": "18.0.0",
      "FIREBASE-CRASH": "16.2.1",
      "CRASHLYTICS": "2.10.1",
      "FIREBASE-DYNAMIC-LINKS": "18.0.0",
      "FIREBASE-INVITES": "17.0.0",
      "FIREBASE-INAPPMESSAGING": "18.0.1",
      "FIREBASE-INAPPMESSAGING-DISPLAY": "18.0.1",
      "FIREBASE-ML-VISION": "21.0.0",
      "FIREBASE-ML-VISION-IMAGE-LABEL-MODEL": "18.0.0",
      "FIREBASE-ML-VISION-FACE-MODEL": "18.0.0",
      "FIREBASE-ML-VISION-OBJECT-DETECTION-MODEL": "17.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-LANGUAGE-ID-MODEL": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-TRANSLATE-MODEL": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-SMART-REPLY-MODEL": "20.0.0",
      "FIREBASE-ML-MODEL-INTERPRETER": "20.0.0",
      "FIREBASE-ML-VISION-AUTOML": "17.0.0",
      "FIREBASE-PERF": "18.0.0",
      "FIREBASE-DATABASE": "18.0.0",
      "FIREBASE-CONFIG": "18.0.0",
      "PLAY-SERVICES-ADS": "18.0.0",
      "PLAY-SERVICES-ADS-IDENTIFIER": "17.0.0",
      "PLAY-SERVICES-ADS-LITE": "18.0.0",
      "PLAY-SERVICES-AFS-NATIVE": "17.0.0",
      "PLAY-SERVICES-ANALYTICS": "17.0.0",
      "PLAY-SERVICES-ANALYTICS-IMPL": "17.0.0",
      "PLAY-SERVICES-APPINVITE": "18.0.0",
      "PLAY-SERVICES-AUDIENCE": "17.0.0",
      "PLAY-SERVICES-AUTH": "17.0.0",
      "PLAY-SERVICES-AUTH-API-PHONE": "17.0.0",
      "PLAY-SERVICES-AWARENESS": "17.0.0",
      "PLAY-SERVICES-BASE": "17.0.0",
      "PLAY-SERVICES-BASEMENT": "17.0.0",
      "PLAY-SERVICES-CAST": "17.0.0",
      "PLAY-SERVICES-CAST-FRAMEWORK": "17.0.0",
      "PLAY-SERVICES-CLEARCUT": "17.0.0",
      "PLAY-SERVICES-CRONET": "17.0.0",
      "PLAY-SERVICES-DRIVE": "17.0.0",
      "PLAY-SERVICES-FIDO": "18.0.0",
      "PLAY-SERVICES-FITNESS": "17.0.0",
      "PLAY-SERVICES-FLAGS": "17.0.0",
      "PLAY-SERVICES-GAMES": "18.0.0",
      "PLAY-SERVICES-GASS": "18.0.0",
      "PLAY-SERVICES-GCM": "17.0.0",
      "PLAY-SERVICES-IDENTITY": "17.0.0",
      "PLAY-SERVICES-IID": "17.0.0",
      "PLAY-SERVICES-INSTANTAPPS": "17.0.0",
      "PLAY-SERVICES-LOCATION": "17.0.0",
      "PLAY-SERVICES-MAPS": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT-API": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT-IMPL": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT-SDK": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT-SDK-API": "17.0.0",
      "PLAY-SERVICES-NEARBY": "17.0.0",
      "PLAY-SERVICES-OSS-LICENSES": "17.0.0",
      "PLAY-SERVICES-PANORAMA": "17.0.0",
      "PLAY-SERVICES-PHENOTYPE": "17.0.0",
      "PLAY-SERVICES-PLACES": "17.0.0",
      "PLAY-SERVICES-PLACES-PLACEREPORT": "17.0.0",
      "PLAY-SERVICES-PLUS": "17.0.0",
      "PLAY-SERVICES-SAFETYNET": "17.0.0",
      "PLAY-SERVICES-STATS": "17.0.0",
      "PLAY-SERVICES-TAGMANAGER": "17.0.0",
      "PLAY-SERVICES-TAGMANAGER-API": "17.0.0",
      "PLAY-SERVICES-TAGMANAGER-V4-IMPL": "17.0.0",
      "PLAY-SERVICES-TASKS": "17.0.0",
      "PLAY-SERVICES-VISION": "18.0.0",
      "PLAY-SERVICES-VISION-COMMON": "18.0.0",
      "PLAY-SERVICES-VISION-IMAGE-LABEL": "18.0.0",
      "PLAY-SERVICES-WALLET": "17.0.0",
      "PLAY-SERVICES-WEARABLE": "17.0.0"
    },
    "cordova-android-support-gradle-release": {
      "FIREBASE-CORE": "17.0.0",
      "FIREBASE-ADS": "18.0.0",
      "FIREBASE-ANALYTICS": "17.0.0",
      "FIREBASE-APPINDEXING": "19.0.0",
      "FIREBASE-AUTH": "18.0.0",
      "FIREBASE-FIRESTORE": "20.0.0",
      "FIREBASE-FUNCTIONS": "18.0.0",
      "FIREBASE-MESSAGING": "19.0.0",
      "FIREBASE-STORAGE": "18.0.0",
      "FIREBASE-CRASH": "16.2.1",
      "CRASHLYTICS": "2.10.1",
      "FIREBASE-DYNAMIC-LINKS": "18.0.0",
      "FIREBASE-INVITES": "17.0.0",
      "FIREBASE-INAPPMESSAGING": "18.0.1",
      "FIREBASE-INAPPMESSAGING-DISPLAY": "18.0.1",
      "FIREBASE-ML-VISION": "21.0.0",
      "FIREBASE-ML-VISION-IMAGE-LABEL-MODEL": "18.0.0",
      "FIREBASE-ML-VISION-FACE-MODEL": "18.0.0",
      "FIREBASE-ML-VISION-OBJECT-DETECTION-MODEL": "17.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-LANGUAGE-ID-MODEL": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-TRANSLATE-MODEL": "20.0.0",
      "FIREBASE-ML-NATURAL-LANGUAGE-SMART-REPLY-MODEL": "20.0.0",
      "FIREBASE-ML-MODEL-INTERPRETER": "20.0.0",
      "FIREBASE-ML-VISION-AUTOML": "17.0.0",
      "FIREBASE-PERF": "18.0.0",
      "FIREBASE-DATABASE": "18.0.0",
      "FIREBASE-CONFIG": "18.0.0",
      "PLAY-SERVICES-ADS": "18.0.0",
      "PLAY-SERVICES-ADS-IDENTIFIER": "17.0.0",
      "PLAY-SERVICES-ADS-LITE": "18.0.0",
      "PLAY-SERVICES-AFS-NATIVE": "17.0.0",
      "PLAY-SERVICES-ANALYTICS": "17.0.0",
      "PLAY-SERVICES-ANALYTICS-IMPL": "17.0.0",
      "PLAY-SERVICES-APPINVITE": "18.0.0",
      "PLAY-SERVICES-AUDIENCE": "17.0.0",
      "PLAY-SERVICES-AUTH": "17.0.0",
      "PLAY-SERVICES-AUTH-API-PHONE": "17.0.0",
      "PLAY-SERVICES-AWARENESS": "17.0.0",
      "PLAY-SERVICES-BASE": "17.0.0",
      "PLAY-SERVICES-BASEMENT": "17.0.0",
      "PLAY-SERVICES-CAST": "17.0.0",
      "PLAY-SERVICES-CAST-FRAMEWORK": "17.0.0",
      "PLAY-SERVICES-CLEARCUT": "17.0.0",
      "PLAY-SERVICES-CRONET": "17.0.0",
      "PLAY-SERVICES-DRIVE": "17.0.0",
      "PLAY-SERVICES-FIDO": "18.0.0",
      "PLAY-SERVICES-FITNESS": "17.0.0",
      "PLAY-SERVICES-FLAGS": "17.0.0",
      "PLAY-SERVICES-GAMES": "18.0.0",
      "PLAY-SERVICES-GASS": "18.0.0",
      "PLAY-SERVICES-GCM": "17.0.0",
      "PLAY-SERVICES-IDENTITY": "17.0.0",
      "PLAY-SERVICES-IID": "17.0.0",
      "PLAY-SERVICES-INSTANTAPPS": "17.0.0",
      "PLAY-SERVICES-LOCATION": "17.0.0",
      "PLAY-SERVICES-MAPS": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT-API": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT-IMPL": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT-SDK": "17.0.0",
      "PLAY-SERVICES-MEASUREMENT-SDK-API": "17.0.0",
      "PLAY-SERVICES-NEARBY": "17.0.0",
      "PLAY-SERVICES-OSS-LICENSES": "17.0.0",
      "PLAY-SERVICES-PANORAMA": "17.0.0",
      "PLAY-SERVICES-PHENOTYPE": "17.0.0",
      "PLAY-SERVICES-PLACES": "17.0.0",
      "PLAY-SERVICES-PLACES-PLACEREPORT": "17.0.0",
      "PLAY-SERVICES-PLUS": "17.0.0",
      "PLAY-SERVICES-SAFETYNET": "17.0.0",
      "PLAY-SERVICES-STATS": "17.0.0",
      "PLAY-SERVICES-TAGMANAGER": "17.0.0",
      "PLAY-SERVICES-TAGMANAGER-API": "17.0.0",
      "PLAY-SERVICES-TAGMANAGER-V4-IMPL": "17.0.0",
      "PLAY-SERVICES-TASKS": "17.0.0",
      "PLAY-SERVICES-VISION": "18.0.0",
      "PLAY-SERVICES-VISION-COMMON": "18.0.0",
      "PLAY-SERVICES-VISION-IMAGE-LABEL": "18.0.0",
      "PLAY-SERVICES-WALLET": "17.0.0",
      "PLAY-SERVICES-WEARABLE": "17.0.0",
      "ANDROID_SUPPORT_VERSION": "27.+"
    },
    "cordova-plugin-camera": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+"
    },
    "cordova-plugin-device": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+"
    },
    "cordova-plugin-file": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+"
    },
    "cordova-plugin-file-transfer": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+"
    },
    "cordova-plugin-ionic-keyboard": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+"
    },
    "cordova-plugin-splashscreen": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+"
    },
    "cordova-plugin-statusbar": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+"
    },
    "cordova-plugin-whitelist": {
      "ANDROID_SUPPORT_V4_VERSION": "27.+",
      "ANDROID_SUPPORT_V7_VERSION": "27.+"
    },
    "cordova-plugin-androidx-adapter": {},
    "@havesource/cordova-plugin-push": {
      "ANDROID_SUPPORT_V13_VERSION": "28.0.0",
      "FCM_VERSION": "18.+",
      "ANDROIDX_CORE_VERSION": "1.6.+"
    },
    "cordova-plugin-customurlscheme": {
      "URL_SCHEME": "sample",
      "ANDROID_SCHEME": "sample",
      "ANDROID_HOST": " ",
      "ANDROID_PATHPREFIX": "/"
    },
    "cordova-plugin-wifi-manager": {}
  }
}
--- End of Cordova JSON Snippet ---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant