arnesson / cordova-plugin-firebase

Cordova plugin for Google Firebase
http://arnesson.github.io/cordova-plugin-firebase
MIT License
1k stars 1.55k forks source link

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

Open salmanworkgit opened 3 years ago

salmanworkgit commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

I have it too

dmitry-salnikov commented 3 years ago

same problem, any updates on this?

Furkan-Ozturk commented 3 years ago

I solved the problem. It is about android version. Cordova supports only up to 8.X.X. Just type “cordova platform add android@8.0.0”

dmitry-salnikov commented 3 years ago

@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 cordova-android@9.0.0?

cinnamon-doge commented 3 years ago

@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 cordova-android@9.0.0?

Agreed, it would seem prudent to add support for cordova-android@9.0.0. I've currently downgraded to 8.0.0, but this is a temporary fix at best.

mvergara2020 commented 3 years ago

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 commented 3 years ago

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 android@9.0.0

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 cordova-plugin-firebase-lib@3.0.0 (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'

8) cordova build android

9) 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 commented 3 years ago

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 commented 3 years ago

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 android@8.0.0
ionic cordova resources
ionic cordova resources --icon
ionic cordova plugin add cordova-android-support-gradle-release --fetch
Atalus commented 3 years ago

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 android@9.0.0
  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 cordova-plugin-firebase-lib@3.0.0 (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 commented 3 years ago

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 commented 3 years ago

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

lucabartoli commented 3 years ago

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 android@8.0.0
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 commented 3 years ago

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?

Heshyo commented 3 years ago

@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 commented 2 years ago

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 android@9.0.0
  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 cordova-plugin-firebase-lib@3.0.0 (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 commented 2 years ago

Any updates on this topic? I have error for Cordova-android@9.1.0

mashrurbd commented 2 years ago

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

TildeGv9 commented 2 years ago

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

mashrurbd commented 2 years ago

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

TildeGv9 commented 2 years ago

So, Is there no fix for this build error?

mashrurbd commented 2 years ago

There is no fix I guess.

cinnamon-doge commented 2 years ago

@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 commented 2 years ago

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