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

Failed to install 'cordova-plugin-firebase': Error: Uh oh! #1154

Open
salmanworkgit opened this issue Aug 24, 2020 · 25 comments
Open

Failed to install 'cordova-plugin-firebase': Error: Uh oh! #1154

salmanworkgit opened this issue Aug 24, 2020 · 25 comments

Comments

@salmanworkgit
Copy link

Installing "cordova-plugin-firebase" for android
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-firebase': Error: Uh oh!
EPERM: operation not permitted, unlink 'E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\app\src\main'
at Object.unlinkSync (fs.js:1136:3)
at mayCopyFile (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\cordova\node_modules\fs-extra\lib\copy-sync\copy-sync.js:59:8)
at onFile (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\cordova\node_modules\fs-extra\lib\copy-sync\copy-sync.js:54:10)
at getStats (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\cordova\node_modules\fs-extra\lib\copy-sync\copy-sync.js:48:44)
at startCopy (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\cordova\node_modules\fs-extra\lib\copy-sync\copy-sync.js:38:10)
at handleFilterAndCopy (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\cordova\node_modules\fs-extra\lib\copy-sync\copy-sync.js:33:10)
at Object.copySync (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\cordova\node_modules\fs-extra\lib\copy-sync\copy-sync.js:26:10)
at copyFile (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\cordova\lib\pluginHandlers.js:223:12)
at install (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\cordova\lib\pluginHandlers.js:61:13)
Uh oh!
EPERM: operation not permitted, unlink 'E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\platforms\android\app\src\main'
at ActionStack.process (E:\android_project\Freelancers\chat-app\NewScript\fm-selection-367293_02-58-08\Chatvybz-updated\ionic-5-chatvybe\mainFile\node_modules\cordova-common\src\ActionStack.js:56:25)

@dan1-de
Copy link

dan1-de commented Aug 26, 2020

Same problem here.
I created a blank new ionic project and tried to integrate cordova-plugin-firebase with the following commands:
ionic cordova platform add android
ionic cordova plugin add cordova-plugin-firebase
npm install @ionic-native/firebase

@Furkan-Ozturk
Copy link

I have it too

@dmitry-salnikov
Copy link

same problem, any updates on this?

@Furkan-Ozturk
Copy link

I solved the problem. It is about android version. Cordova supports only up to 8.X.X. Just type “cordova platform add [email protected]

@dmitry-salnikov
Copy link

@Furkan-Ozturk thanks for the comment, but the latest cordova-android version is 9.0.0, we've upgraded it in the project recently. So, the only solution is to downgrade it back? Shouldn't something be fixed in the plugin instead, to enable support of [email protected]?

@cinnamon-doge
Copy link

@Furkan-Ozturk thanks for the comment, but the latest cordova-android version is 9.0.0, we've upgraded it in the project recently. So, the only solution is to downgrade it back? Shouldn't something be fixed in the plugin instead, to enable support of [email protected]?

Agreed, it would seem prudent to add support for [email protected]. I've currently downgraded to 8.0.0, but this is a temporary fix at best.

@mvergara2020
Copy link

mvergara2020 commented Nov 14, 2020

The error occurs in the file "plugins\cordova-plugin-fcm\scripts\fcm_config_files_process.js"

The error occurs when trying to load the file "strings.xml"

Check the path of your "strings.xml" file and update it, I left the following path:

var strings = fs.readFileSync ("platforms/android/app/src/main/res/values/strings.xml"). toString();

Additionally, you can debug the file by adding console.log ("XXXX"); and check where the error is.

image

--> remove all platforms and then install the plugin:

1.- ionic cordova platform rm android
2.- ionic cordova platform rm ios
3.- ionic cordova plugin add cordova-plugin-fcm
4.- ionic cordova platform add android
----------- a) .- If there is errror ===> ionic cordova platform rm android
----------- b) .- Validate the file ===> "plugins \ cordova-plugin-fcm \ scripts \ fcm_config_files_process.js"
----------- c) .- I try to add android again ====> ionic cordova platform add android
----------- d) .- Iterate until the solution is found

At the end, also check the writing of the "strings.xml" file

fs.writeFileSync ("platforms/android/app/src/main/res/values/strings.xml", strings);

@ozmenbetul
Copy link

ozmenbetul commented Nov 19, 2020

Hi, all

We're having the same problem. We found a solution. Here's our workaround:

Studying the error message that occurs during the installation of the firebase plugin, we made a debug session and found that things were going wrong while the plugin was trying to copy google-services.json file from the plugin folder to the project folder.

The error message was:
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-firebase-lib': Error: Uh oh!
EPERM: operation not permitted, unlink '[My project folder]\apk\platforms\android\app\src\main'

It's something to the with file write permissions but we couldn't solve this by changing folder permissions and indexing.

From the stack trace, we saw that the copy operation was handled by the mayCopyFile function in the copy-sync.js javascript file that was located in the ..\apk\node_modules\fs-extra\lib\copy-sync folder.

Here's the function body:
function mayCopyFile (srcStat, src, dest, opts) {
if (opts.overwrite) {
fs.unlinkSync(dest)
return copyFile(srcStat, src, dest, opts)
} else if (opts.errorOnExist) {
throw new Error('${dest}' already exists)
}
}

fsunlinkSync and copyFile calls here crashes the installation. We couldn't proceed with the debug further, perhaps it would be better to proceed but we stopped here and found this solution:

Since these lines of code is trying to copy google-services.json file from the
..\apk\plugins\cordova-plugin-firebase\src\android
location to the
..\apk\platforms\android\app\src\main destination,
we decided to do this copy manually.

So here are the steps we followed:

  1. Make sure you have a clean cordova project folder with no firebase plugin.

  2. Have the android platform 9.0.0, if already not:
    cordova platform rm android
    cordova platform add [email protected]

  3. Comment out the lines fsunlinkSync and copyFile in the mayCopyFile function in the ..\apk\node_modules\fs-extra\lib\copy-sync copy-sync.js file.

  4. install firebase plugin:
    cordova plugin add [email protected]
    (We've always been using this lib. Unfortunately cordova-plugin-firebase gives other build errors)

  5. See that the plugin is installed and the platform is android 9.0.0
    cordova plugin ls
    cordova platform ls

  6. Copy google-services.json file from
    ..\apk\plugins\cordova-plugin-firebase\src\android
    location to the
    ..\apk\platforms\android\app\src\main destination,
    manually.

  7. Before the cordova build, uncomment the code lines you commented out in the 3rd step, because cordova build is going to copy lots of files from some source location to some destination location that isn't smart to copy manually.

  8. Edit build.gradle file in the apk\platforms\android folder (change the gradle version appropriately):
    classpath 'io.fabric.tools:gradle:1.28.0'

  9. cordova build android

  10. cordova run android

This worked. Of course, we added the cordova-device-plugin, edited the config.xml, added google-services.json to the project root folder etc as usual prerequisites, to make the plugin work.

Hope this helps.

My best,
Betul

@idcadeleonlangure
Copy link

I have the exact same error and I am following this workaround but seems to have other implications. Is there a way to find out when will a consistent version of the plugin be available?

@mvergara2020
Copy link

mvergara2020 commented Nov 20, 2020

Hi,

Discard installing "cordova-plugin-firebase", here is the detail of what you install, luck (I installed it so):

ionic cordova plugin add cordova-plugin-fcm-with-dependency-updated-apns
npm install --save @ionic-native/fcm@4
ionic cordova platform add [email protected]
ionic cordova resources
ionic cordova resources --icon
ionic cordova plugin add cordova-android-support-gradle-release --fetch

@Atalus
Copy link

Atalus commented Nov 26, 2020

Hi, all

We're having the same problem. We found a solution. Here's our workaround:

Studying the error message that occurs during the installation of the firebase plugin, we made a debug session and found that things were going wrong while the plugin was trying to copy google-services.json file from the plugin folder to the project folder.

The error message was:
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-firebase-lib': Error: Uh oh!
EPERM: operation not permitted, unlink '[My project folder]\apk\platforms\android\app\src\main'

It's something to the with file write permissions but we couldn't solve this by changing folder permissions and indexing.

From the stack trace, we saw that the copy operation was handled by the mayCopyFile function in the copy-sync.js javascript file that was located in the ..\apk\node_modules\fs-extra\lib\copy-sync folder.

Here's the function body:
function mayCopyFile (srcStat, src, dest, opts) {
if (opts.overwrite) {
fs.unlinkSync(dest)
return copyFile(srcStat, src, dest, opts)
} else if (opts.errorOnExist) {
throw new Error('${dest}' already exists)
}
}

fsunlinkSync and copyFile calls here crashes the installation. We couldn't proceed with the debug further, perhaps it would be better to proceed but we stopped here and found this solution:

Since these lines of code is trying to copy google-services.json file from the
..\apk\plugins\cordova-plugin-firebase\src\android
location to the
..\apk\platforms\android\app\src\main destination,
we decided to do this copy manually.

So here are the steps we followed:

  1. Make sure you have a clean cordova project folder with no firebase plugin.
  2. Have the android platform 9.0.0, if already not:
    cordova platform rm android
    cordova platform add [email protected]
  3. Comment out the lines fsunlinkSync and copyFile in the mayCopyFile function in the ..\apk\node_modules\fs-extra\lib\copy-sync copy-sync.js file.
  4. install firebase plugin:
    cordova plugin add [email protected]
    (We've always been using this lib. Unfortunately cordova-plugin-firebase gives other build errors)
  5. See that the plugin is installed and the platform is android 9.0.0
    cordova plugin ls
    cordova platform ls
  6. Copy google-services.json file from
    ..\apk\plugins\cordova-plugin-firebase\src\android
    location to the
    ..\apk\platforms\android\app\src\main destination,
    manually.
  7. Before the cordova build, uncomment the code lines you commented out in the 3rd step, because cordova build is going to copy lots of files from some source location to some destination location that isn't smart to copy manually.
  8. Edit build.gradle file in the apk\platforms\android folder (change the gradle version appropriately):
    classpath 'io.fabric.tools:gradle:1.28.0'
  9. cordova build android
  10. cordova run android

This worked. Of course, we added the cordova-device-plugin, edited the config.xml, added google-services.json to the project root folder etc as usual prerequisites, to make the plugin work.

Hope this helps.

My best,
Betul

You really saved my day, that's a 100% solution!

@nixiam
Copy link

nixiam commented Dec 1, 2020

Hi,
this solution doesn't work for me. I have the same error message also after comment out line 58 and 59 of copy-sync.js

@bryanfaundez
Copy link

Has anyone tried to solve it with other alternatives? I can't solve the problem

@lucabartoli
Copy link

lucabartoli commented Dec 24, 2020

Hi,

Discard installing "cordova-plugin-firebase", here is the detail of what you install, luck (I installed it so):

ionic cordova plugin add cordova-plugin-fcm-with-dependency-updated-apns
npm install --save @ionic-native/fcm@4
ionic cordova platform add [email protected]
ionic cordova resources
ionic cordova resources --icon
ionic cordova plugin add cordova-android-support-gradle-release --fetch

Not a solution, as FCM is just the Firebase part for push notifications.
For example, I use Firebase for push notifications and tracking.
Didn't find a proper solution yet. I tried all the possible combinations of cordova-android / firebase and nothing worked.

Anyone found a solution?

@josevavia
Copy link

Any update on this?

I have the same problem trying install 2.0.5

I want to use this plugin only for push notifications, because using cordova-plugin-fcm-with-dependecy-updated I have an error too: andrehtissot/cordova-plugin-fcm-with-dependecy-updated#232

Any alternatives?

@Heshyo
Copy link

Heshyo commented Mar 16, 2021

@josevavia If you're only after push notifications on Android, you can use https://github.com/havesource/cordova-plugin-push This is a replacement for https://github.com/phonegap/phonegap-plugin-push . It works well for me on Android, but I can't make it work on iOS though.

EDIT: it's working on iOS now.

@mashrurbd
Copy link

Hi, all

We're having the same problem. We found a solution. Here's our workaround:

Studying the error message that occurs during the installation of the firebase plugin, we made a debug session and found that things were going wrong while the plugin was trying to copy google-services.json file from the plugin folder to the project folder.

The error message was:
Error during processing of action! Attempting to revert...
Failed to install 'cordova-plugin-firebase-lib': Error: Uh oh!
EPERM: operation not permitted, unlink '[My project folder]\apk\platforms\android\app\src\main'

It's something to the with file write permissions but we couldn't solve this by changing folder permissions and indexing.

From the stack trace, we saw that the copy operation was handled by the mayCopyFile function in the copy-sync.js javascript file that was located in the ..\apk\node_modules\fs-extra\lib\copy-sync folder.

Here's the function body:
function mayCopyFile (srcStat, src, dest, opts) {
if (opts.overwrite) {
fs.unlinkSync(dest)
return copyFile(srcStat, src, dest, opts)
} else if (opts.errorOnExist) {
throw new Error('${dest}' already exists)
}
}

fsunlinkSync and copyFile calls here crashes the installation. We couldn't proceed with the debug further, perhaps it would be better to proceed but we stopped here and found this solution:

Since these lines of code is trying to copy google-services.json file from the
..\apk\plugins\cordova-plugin-firebase\src\android
location to the
..\apk\platforms\android\app\src\main destination,
we decided to do this copy manually.

So here are the steps we followed:

  1. Make sure you have a clean cordova project folder with no firebase plugin.
  2. Have the android platform 9.0.0, if already not:
    cordova platform rm android
    cordova platform add [email protected]
  3. Comment out the lines fsunlinkSync and copyFile in the mayCopyFile function in the ..\apk\node_modules\fs-extra\lib\copy-sync copy-sync.js file.
  4. install firebase plugin:
    cordova plugin add [email protected]
    (We've always been using this lib. Unfortunately cordova-plugin-firebase gives other build errors)
  5. See that the plugin is installed and the platform is android 9.0.0
    cordova plugin ls
    cordova platform ls
  6. Copy google-services.json file from
    ..\apk\plugins\cordova-plugin-firebase\src\android
    location to the
    ..\apk\platforms\android\app\src\main destination,
    manually.
  7. Before the cordova build, uncomment the code lines you commented out in the 3rd step, because cordova build is going to copy lots of files from some source location to some destination location that isn't smart to copy manually.
  8. Edit build.gradle file in the apk\platforms\android folder (change the gradle version appropriately):
    classpath 'io.fabric.tools:gradle:1.28.0'
  9. cordova build android
  10. cordova run android

This worked. Of course, we added the cordova-device-plugin, edited the config.xml, added google-services.json to the project root folder etc as usual prerequisites, to make the plugin work.

Hope this helps.

My best,
Betul

This is not working. Please help me on this topic.

@TildeGv9
Copy link

Any updates on this topic? I have error for [email protected]

@mashrurbd
Copy link

mashrurbd commented Mar 16, 2022 via email

@TildeGv9
Copy link

Unfortunately I'm working on a Cordova based project and I can't switch

@mashrurbd
Copy link

mashrurbd commented Mar 16, 2022 via email

@TildeGv9
Copy link

So, Is there no fix for this build error?

@mashrurbd
Copy link

There is no fix I guess.

@cinnamon-doge
Copy link

@TildeGv9 @mashrurbd I've successfully migrated my Ionic Framework v1 app to cordova-plugin-firebasex. I do have one issue with it at the moment, but otherwise I can highly recommend jumping aboard.

@mashrurbd
Copy link

mashrurbd commented May 4, 2022 via email

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