Failed to install 'cordova-plugin-firebase': Error: Uh oh!
salmanworkgit opened this issue Β· 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)
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
I have it too
same problem, any updates on this?
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β
@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
?
@Furkan-Ozturk thanks for the comment, but the latest
cordova-android
version is9.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 ofcordova-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.
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.
--> 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);
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:
-
Make sure you have a clean cordova project folder with no firebase plugin.
-
Have the android platform 9.0.0, if already not:
cordova platform rm android
cordova platform add android@9.0.0 -
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.
-
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) -
See that the plugin is installed and the platform is android 9.0.0
cordova plugin ls
cordova platform ls -
Copy google-services.json file from
..\apk\plugins\cordova-plugin-firebase\src\android
location to the
..\apk\platforms\android\app\src\main destination,
manually. -
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.
-
Edit build.gradle file in the apk\platforms\android folder (change the gradle version appropriately):
classpath 'io.fabric.tools:gradle:1.28.0' -
cordova build android
-
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
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?
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
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:
- Make sure you have a clean cordova project folder with no firebase plugin.
- Have the android platform 9.0.0, if already not:
cordova platform rm android
cordova platform add android@9.0.0- 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.
- 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)- See that the plugin is installed and the platform is android 9.0.0
cordova plugin ls
cordova platform ls- Copy google-services.json file from
..\apk\plugins\cordova-plugin-firebase\src\android
location to the
..\apk\platforms\android\app\src\main destination,
manually.- 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.
- Edit build.gradle file in the apk\platforms\android folder (change the gradle version appropriately):
classpath 'io.fabric.tools:gradle:1.28.0'- cordova build android
- 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!
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
Has anyone tried to solve it with other alternatives? I can't solve the problem
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?
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?
@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.
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:
- Make sure you have a clean cordova project folder with no firebase plugin.
- Have the android platform 9.0.0, if already not:
cordova platform rm android
cordova platform add android@9.0.0- 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.
- 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)- See that the plugin is installed and the platform is android 9.0.0
cordova plugin ls
cordova platform ls- Copy google-services.json file from
..\apk\plugins\cordova-plugin-firebase\src\android
location to the
..\apk\platforms\android\app\src\main destination,
manually.- 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.
- Edit build.gradle file in the apk\platforms\android folder (change the gradle version appropriately):
classpath 'io.fabric.tools:gradle:1.28.0'- cordova build android
- 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.
Any updates on this topic? I have error for Cordova-android@9.1.0
Unfortunately I'm working on a Cordova based project and I can't switch
So, Is there no fix for this build error?
There is no fix I guess.
@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.