Cannot find module 'compare-func' Cordova Android - android-studio

I've got a Cordova v10.0.0 project using Cordova Android v9.0.0, I'm experiencing a problem when trying to build the project for Android, I'm getting the following error:
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=/Users/MYUSER/Library/Android/sdk (DEPRECATED)
Failed to instantiate ProjectBuilder builder: Error: Cannot find module 'compare-func'
I've tried removing my Node Modules folder, running a cordova clean android and re-installing with npm install. Not quite sure why I'm getting this error.

I faced the same issue and I installed compare-func npm package (Link) (npm i compare-func) and it worked for me.

Related

ANDROID_SDK_ROOT=undefined (recommended setting) while building ionic app using Cordova for Android device

I am trying to build an ionic app for Android device with Cordova using the below command from VSCode.
ionic cordova build android --prod --release
But I'm getting this error:
cordova.cmd build android --release
Checking Java JDK and Android SDK versions
ANDROID_SDK_ROOT=undefined (recommended setting)
ANDROID_HOME=C:\Users\tanmay\AppData\Local\Android\sdk (DEPRECATED)
Could not find an installed version of Gradle either in Android Studio,
or on your system to install the gradle wrapper. Please include gradle
in your path, or install Android Studio
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --release exited with exit code 1.
I have already installed JDK, Android Studio. I also have setup the environment variable ANDROID_SDK_ROOT with the correct SDK path. But still no luck.
I am using
Android Studio 3.6.1,
Gradle 6.3,
Cordova 8.1,
on Windows 10.
I guess I am somewhere missing the setting the ANDROID_SDK_ROOT but I'm not sure where.
You can check if Java JDK, Android SDK, Gradle are properly installed before building an app.
To do so, you can run the following command :
cordova requirements android --verbose
It will show, what is missing and after that, you may install it if you haven't installed it or you may check for the correct path in the Environment Variables.
If you have an android studio installed, you need not to worry about this error on terminal, as until this error cordova will update your android package in platforms directory.
Open your Android Studio.
Select open existing project and browse to select your /platforms/android folder in
project directory.
It will open in android and will be build success
I had the same error.
I solved it by using Gradle 5.6.3 instead of the newer versions.
For anyone as dumb as I was that also thought you could setup and run a cordova project on android without having java, gradle or android studio installed: Once you installed all those things, delete your cordova project's node_modules, platforms, plugins and www folders and set them up again (i.e. rerun npm i, cordova platform add android, npm run build, etc) before trying to run the cordova project again. In my case I'm trying to run cordova run android which caused the same error that OP's getting.
NOTE: I have zero experience with cordova. I have to get a very specific cordova/webpack template up and running locally, and the advice I'm giving in this answer is what worked for me. YMMV.

Cordova build and run facing error variables.forEach is not a function

My ionic project suddenly doesn't response on any Cordova build/run command.
Macbooks-MBP:upost Kira$ cordova run ios
Error: variables.forEach is not a function
Macbooks-MBP:upost Kira$ cordova run android
Error: variables.forEach is not a function
Macbooks-MBP:upost Kira$ cordova build ios
Error: variables.forEach is not a function
Macbooks-MBP:upost Kira$ cordova build android
Error: variables.forEach is not a function
Macbooks-MBP:upost Kira$
here is the Cordova -d build ios response
Macbooks-MBP:upost Kira$ cordova -d build ios
No scripts found for hook "before_build".
No scripts found for hook "before_prepare".
Checking config.xml and package.json for saved platforms that haven't been added to the project
Config.xml and package.json platforms are the same. No pkg.json modification.
Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
PlatformApi successfully found for platform ios
Checking config.xml for saved plugins that haven't been added to the project
Error: variables.forEach is not a function
Step I had tried:
Clone another new project
reinstall all node, npm, Cordova, ionic
Try in sample project, it works
Copy project from others, no working also
Remove/add Cordova platform for both iOS and android
Component version:
Cordova v7.0.1
ionic v3.5.0
node v6.11.1
npm v3.10.10
remove ios-sim under platforms/cordova/node_modules/
type command npm i -g install ios-sim#latest
and also npm i -g install ios-deploy#latest
then Cordova build ios or Cordova run ios will work

Unable to add plugins to cordova project. npm error?

I have a Cordova application and want to add a plugin to my Cordova project. It worked yesterday!
What I did:
Updated Android Studio to 3.x
Updated Cordova
If I want use the cordova add command, I get this error:
What should I do?
Hard Reset it: Try to remove that plugin you installed yesterday, maybe do a clean install of Cordova or update all dependencies and add missing through Gradle and then finally go for installing the plugins. Somehow, I feel that Cordova version or some dependency mismatch is giving birth to such problems.

error building phonegap application : Error installing local npm package

I use visual studio 2015 to create a mobile app using javascript apache cordova app. but when I want to build it , I got two errors:
Error installing local npm package.
and this error :
Could not find module 'C:\Users\rayban pc\AppData\Roaming\npm\node_modules\vs-tac\app.js'. Please Go to Tools --> Options --> Tools for Apache Cordova --> Cordova Tools --> Clear Cordova Cache and try building again
I clear cache , but error occur again.
I set environment variables for android sdk , java , ant and node.js correctly.
please help me solve this error.
What update of TACO are you on? Earlier versions of TACO sometimes have npm and Node versioning issues. Update to the latest version (VS15, Update 8) http://taco.visualstudio.com/en-us/docs/release-update-8/, which sandboxes Node and npm. After you update, try to build a new blank project.
My Problem Solve when I update my android sdk and get all version of sdk.

Cordova inAppBrowser plugin issue on windows

so I've been trying to add this plugin with command
cordova plugin add
https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
which worked on MAC and Linux after
npm update -g cordova
but on windows I'm still getting
cannot read property 'install' of undefined
Moreover - when I'm trying to uninstall ( cordova plugin rm org.apache.cordova.inappbrowser ) then I'm getting
cannot read property 'uninstall' of undefined
Weird thing is that I have two cordova folders - one in
C:\Users\me\AppData\Roaming\npm\node_modules and the second one in
C:\Users\me\AppData\Roaming\npm\node_modules\phonegap\node_modules . Path which I added to my environmental variables is C:\Users\mati\AppData\Roaming\npm\node_modules\phonegap\node_modules\.bin
I think that this is the problem reported about a week ago as CB-6008 on the Cordova bug tracker.
It may be a symptom of having an out-of-date cordova installation still. The issue there was solved by removing and reinstalling Cordova to ensure that the latest version was in use.
Delete the content of your platforms and plugins folder. re-install your plugins and the problem should be gone. In my case the following command
phonegap local plugin add org.apache.cordova.inappbrowser
produced -> [error] Cannot read property 'install' of undefined
and the above procedure fixed it.
Have you added a platform to your cordova project (before trying to add a plugin)?
npm update -g cordova
cordova create myproject
cd myproject
cordova platform add android
cordova plugin add _
I think the undefined error means a dependency of the add plugin command is not there.
For me, the solution was to update plugman module:
npm install -g plugman

Resources