cordova-plugin-firebase icon indicating copy to clipboard operation
cordova-plugin-firebase copied to clipboard

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

Open salmanworkgit opened this issue 4 years ago • 25 comments

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)

salmanworkgit avatar Aug 24 '20 04:08 salmanworkgit

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

dan1-de avatar Aug 26 '20 11:08 dan1-de

I have it too

Furkan-Ozturk avatar Aug 30 '20 21:08 Furkan-Ozturk

same problem, any updates on this?

dmitry-salnikov avatar Sep 03 '20 12:09 dmitry-salnikov

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

Furkan-Ozturk avatar Sep 03 '20 13:09 Furkan-Ozturk

@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]?

dmitry-salnikov avatar Sep 03 '20 14:09 dmitry-salnikov

@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.

cinnamon-doge avatar Nov 13 '20 23:11 cinnamon-doge

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);

mvergara2020 avatar Nov 14 '20 15:11 mvergara2020

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

ozmenbetul avatar Nov 19 '20 08:11 ozmenbetul

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?

idcadeleonlangure avatar Nov 19 '20 22:11 idcadeleonlangure

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

mvergara2020 avatar Nov 20 '20 15:11 mvergara2020

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!

Atalus avatar Nov 26 '20 23:11 Atalus

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

nixiam avatar Dec 01 '20 19:12 nixiam

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

bryanfaundez avatar Dec 16 '20 13:12 bryanfaundez

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?

lucabartoli avatar Dec 24 '20 11:12 lucabartoli

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: https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated/issues/232

Any alternatives?

josevavia avatar Mar 09 '21 11:03 josevavia

@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.

Heshyo avatar Mar 16 '21 02:03 Heshyo

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.

mashrurbd avatar Sep 15 '21 11:09 mashrurbd

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

TildeGv9 avatar Mar 16 '22 12:03 TildeGv9

Switch to flutter

On Wed, Mar 16, 2022, 18:22 TildeGv9 @.***> wrote:

Any updates on this topic? I have error for @.***

— Reply to this email directly, view it on GitHub https://github.com/arnesson/cordova-plugin-firebase/issues/1154#issuecomment-1069068963, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7TE43KNAVXPI24GIBPOHTVAHHBNANCNFSM4QJCS77Q . You are receiving this because you commented.Message ID: @.***>

mashrurbd avatar Mar 16 '22 12:03 mashrurbd

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

TildeGv9 avatar Mar 16 '22 13:03 TildeGv9

Ok, no problem.

On Wed, Mar 16, 2022, 19:53 TildeGv9 @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/arnesson/cordova-plugin-firebase/issues/1154#issuecomment-1069155540, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7TE476FQEZYYLP6FUCONLVAHRVJANCNFSM4QJCS77Q . You are receiving this because you commented.Message ID: @.***>

mashrurbd avatar Mar 16 '22 13:03 mashrurbd

So, Is there no fix for this build error?

TildeGv9 avatar Mar 16 '22 13:03 TildeGv9

There is no fix I guess.

mashrurbd avatar Mar 19 '22 16:03 mashrurbd

@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.

cinnamon-doge avatar May 04 '22 10:05 cinnamon-doge

Congratulations, enjoy fw7.

On Wed, May 4, 2022, 16:05 cinnamon-doge @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/arnesson/cordova-plugin-firebase/issues/1154#issuecomment-1117138287, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7TE4ZJ5ZXW35CYTCUAEHLVIJDYJANCNFSM4QJCS77Q . You are receiving this because you were mentioned.Message ID: @.***>

mashrurbd avatar May 04 '22 12:05 mashrurbd