apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

The "path" argument must be of type string. Received undefined #1525

Closed rchovan closed 1 year ago

rchovan commented 1 year ago

Bug Report

Problem

Android build is working first time after adding android platform, but on second time it show this error "The "path" argument must be of type string. Received undefined". I can only remove and again add platform to make it work.

What is expected to happen?

build application without error

What does actually happen?

build end with error:

...
  copy  res/screen/hdpi/portrait.png platforms\android\app\src\main\res\drawable-port-hdpi\screen.png (updated file)
  copy  res/screen/mdpi/portrait.png platforms\android\app\src\main\res\drawable-port-mdpi\screen.png (updated file)
  copy  res/screen/xhdpi/portrait.png platforms\android\app\src\main\res\drawable-port-xhdpi\screen.png (updated file)
  copy  res/screen/xxhdpi/portrait.png platforms\android\app\src\main\res\drawable-port-xxhdpi\screen.png (updated file)
  copy  res/screen/xxxhdpi/portrait.png platforms\android\app\src\main\res\drawable-port-xxxhdpi\screen.png (updated file)
This app does not have additional resource files defined
Prepared android project successfully
The "path" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (internal/errors.js:322:7)
    at validateString (internal/validators.js:124:11)
    at Object.join (path.js:424:7)
    at ConfigKeeper.get (D:\Projects\master\node_modules\cordova-common\src\ConfigChanges\ConfigKeeper.js:44:32)
    at D:\Projects\master\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:264:51
    at Array.forEach (<anonymous>)
    at PlatformMunger._is_conflicting (D:\Projects\master\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:257:21)
    at PlatformMunger.add_config_changes (D:\Projects\master\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:140:59)
    at D:\Projects\master\node_modules\cordova-lib\src\cordova\prepare\platforms.js:66:24
    at async Promise.all (index 0)

Information

System Windows 10 64bit

Command or Code

cordova prepare android

Environment, Platform, Device

Windos 10, Android 10.1.2

Version information

cordova platforms

Installed platforms:
  android 10.1.2
Available platforms:
  browser ^6.0.0
  electron ^3.0.0
  windows ^7.0.0

cordova --version

11.0.0

cordova plugins

com-darryncampbell-cordova-plugin-intent 1.1.7 "Intent Shim"
com-intel-security-cordova-plugin 2.0.3 "APP Security API"
com.loksir.zb 1.0.18 "zb"
cordova-plugin-android-permissions 1.1.3 "Permissions"
cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-bluetooth-serial 0.4.7 "Bluetooth Serial"
cordova-plugin-camera-preview 0.12.1 "cordova-plugin-camera-preview"
cordova-plugin-camera 4.0.4-dev "Camera"
cordova-plugin-cartegraph-cookie-master 1.4.1 "CookieMaster"
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-dialogs 2.0.2 "Notification"
cordova-plugin-file-transfer 2.0.0-dev "File Transfer"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-media 5.0.4 "Media"
cordova-plugin-mobile-ocr 3.1.2 "Textocr"
cordova-plugin-ondestroy 1.0.2 "Cordova onDestroy Plugin"
cordova-plugin-pm80-scanner 0.0.6 "PM80 Scanner"
cordova-plugin-screen-orientation 3.0.2 "Screen Orientation"
cordova-plugin-splashscreen 6.0.0 "Splashscreen"
cordova-plugin-vibration 3.1.1 "Vibration"
cordova-plugin-x-socialsharing 6.0.3 "SocialSharing"
cordova-sqlite-legacy-build-support 1.3.5 "Cordova sqlite legacy build support"
cordova.plugins.diagnostic 5.0.0 "Diagnostic"
es6-promise-plugin 4.2.2 "Promise"
phonegap-plugin-barcodescanner 8.0.0 "BarcodeScanner"

Operating System: Windows 10 64bit, IDE: Vscode / IntelijIDEA

node --version v14.18.3

Checklist

jcesarmobile commented 1 year ago

Can you try using cordova-android 11?

cordova platform rm android
cordova platform add android@latest

If that doesn’t work, can you provide a sample app where the issue can be reproduced?

rchovan commented 1 year ago

Hi, so far I can't use cordova-android 11 because of project dependencies.

android-targetSdkVersion should be greater than or equal to 32.
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\Projects\master\platforms\android\app\build.gradle' line: 20

* What went wrong:
A problem occurred evaluating project ':app'.
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
     Your current JDK is located in  C:\Program Files\Java\jdk1.8.0_301\jre
     You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.
jcesarmobile commented 1 year ago

For the first problem, make sure you don't have a <preference name="android-targetSdkVersion" value="xx" /> entry in your config.xml

For the second problem, you have to use java 11 instead of java 8

jcesarmobile commented 1 year ago

closing since no sample app was provided and no feedback was received since last answers

steveetm commented 1 year ago

In platforms/android/android.json this shows up after the first build

 "undefined": {
        "parents": {
          "AndroidManifest.xml": []
        }
      },
rchovan commented 11 months ago

@steveetm thanks, removing this "undefined" property from android.json fixed build process.

ishigo1987 commented 10 months ago

Same problem for me, do i need to remove the entire code block ?

"undefined": { "parents": { "AndroidManifest.xml": [ { "xml": "<action android:name=\"com.darryncampbell.cordova.plugin.intent.ACTION\" /><category android:name=\"android.intent.category.DEFAULT\" />", "count": 1, "mode": "merge", "plugin": "com-darryncampbell-cordova-plugin-intent" }, { "xml": "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\" />", "count": 1, "mode": "merge", "plugin": "com-darryncampbell-cordova-plugin-intent" }, { "xml": "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\" />", "count": 1, "mode": "merge", "plugin": "com-darryncampbell-cordova-plugin-intent" }, { "xml": "<provider android:authorities=\"${applicationId}.darryncampbell.cordova.plugin.intent.fileprovider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"com.darryncampbell.cordova.plugin.intent.CordovaPluginIntentFileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/provider_paths\" />", "count": 1, "mode": "merge", "plugin": "com-darryncampbell-cordova-plugin-intent" } ] } },

davipromob commented 1 month ago
sudo npm uninstall -g cordova
sudo npm install -g cordova@11.0.0
cordova --version
sudo npm cache clean -f
sudo npm install -g n
sudo n 18.12.0
cordova platform rm ios
cordova platform add ios@6.0.0