operation not permitted, unlink while adding cordova-plugin-firebase plugin in ionic - ionic-framework

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 'F:\ionic\PkjshopMerchant\platforms\android\app\src\main'
at Object.unlinkSync (fs.js:1129:3)
at mayCopyFile (F:\ionic\PkjshopMerchant\platforms\android\cordova\node_modules\fs-extra\lib\copy-sync\copy-sync.js:59:8)

As commented in this link : https://github.com/arnesson/cordova-plugin-firebase/issues/1154
there is a posible solution for it that is not downgrading to cordova#8.0.0
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.

Related

IONIC Package Failed to install ‘onesignal-cordova-plugin’: Error: pod: Command failed with exit code 31

I’m trying to use ionic pro packaging (https://ionicframework.com/pro/package). When building to android everything works fine. But building to IOS gives me this error:
Looking for related GitHub issues on fastlane/fastlane…
\e[91mFailed to upload ipa to storage please retry your build.\e[0m
MAC Iteration 1
MAC verified OK
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
Certificate bag
PKCS7 Data
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2048
/Users/ionic/.fastlane/bin/bundle/lib/ruby/gems/2.2.0/gems/fastlane-2.75.1/fastlane_core/lib/fastlane_core/ui/interface.rb:145:in `shell_error!’: [!] Exit status of command ‘cordova platform add ios --nofetch’ was 1 instead of 0. (FastlaneCore::Interface::FastlaneShellError)
Adding ios project…
Creating Cordova project for the iOS platform:
Path: platforms/ios
Package: com.notified.x
Name: Notified
iOS project created with cordova-ios#4.5.4
Discovered plugin “cordova-plugin-whitelist” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-whitelist#^1.3.3” via npm
Installing “cordova-plugin-whitelist” for ios
Adding cordova-plugin-whitelist to package.json
Saved plugin info for “cordova-plugin-whitelist” to config.xml
Discovered plugin “cordova-plugin-device” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-device#^2.0.2” via npm
Installing “cordova-plugin-device” for ios
Adding cordova-plugin-device to package.json
Saved plugin info for “cordova-plugin-device” to config.xml
Discovered plugin “cordova-plugin-splashscreen” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-splashscreen#^5.0.2” via npm
Installing “cordova-plugin-splashscreen” for ios
Adding cordova-plugin-splashscreen to package.json
Saved plugin info for “cordova-plugin-splashscreen” to config.xml
Discovered plugin “cordova-plugin-ionic-webview” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-ionic-webview#^1.2.1” via npm
Installing “cordova-plugin-ionic-webview” for ios
Adding cordova-plugin-ionic-webview to package.json
Saved plugin info for “cordova-plugin-ionic-webview” to config.xml
Discovered plugin “cordova-plugin-ionic-keyboard” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-ionic-keyboard#^2.1.2” via npm
Installing “cordova-plugin-ionic-keyboard” for ios
Adding cordova-plugin-ionic-keyboard to package.json
Saved plugin info for “cordova-plugin-ionic-keyboard” to config.xml
Discovered plugin “cordova-plugin-app-name” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-app-name#^1.0.4” via npm
Installing “cordova-plugin-app-name” for ios
Adding cordova-plugin-app-name to package.json
Saved plugin info for “cordova-plugin-app-name” to config.xml
Discovered plugin “cordova-plugin-inappbrowser” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-inappbrowser#^3.0.0” via npm
Installing “cordova-plugin-inappbrowser” for ios
Adding cordova-plugin-inappbrowser to package.json
Saved plugin info for “cordova-plugin-inappbrowser” to config.xml
Discovered plugin “cordova-plugin-statusbar” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-statusbar#^2.4.2” via npm
Installing “cordova-plugin-statusbar” for ios
Adding cordova-plugin-statusbar to package.json
Saved plugin info for “cordova-plugin-statusbar” to config.xml
Discovered plugin “cordova-plugin-ionic” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-ionic#^4.1.7” via npm
Installing “cordova-plugin-ionic” for ios
Plugin dependency “cordova-plugin-splashscreen#5.0.2” already fetched, using that version.
Dependent plugin “cordova-plugin-splashscreen” already installed on ios.
Adding cordova-plugin-ionic to package.json
Saved plugin info for “cordova-plugin-ionic” to config.xml
Discovered plugin “cordova-plugin-cocoapod-support” in config.xml. Adding it to the project
Fetching plugin “cordova-plugin-cocoapod-support#^1.5.0” via npm
Installing “cordova-plugin-cocoapod-support” for ios
Adding cordova-plugin-cocoapod-support to package.json
Saved plugin info for “cordova-plugin-cocoapod-support” to config.xml
Discovered plugin “onesignal-cordova-plugin” in config.xml. Adding it to the project
Fetching plugin “onesignal-cordova-plugin#^2.1.0” via npm
Installing “onesignal-cordova-plugin” for ios
Failed to install ‘onesignal-cordova-plugin’: Error: pod: Command failed with exit code 31
at ChildProcess.whenDone (/Users/ionic/builds/TechNotified/notified-mobile-app/platforms/ios/cordova/node_modules/cordova-common/src/superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
Failed to restore plugin “onesignal-cordova-plugin” from config.xml. You might need to try adding it again. Error: Error: pod: Command failed with exit code 31
Searching for new pods
Checking config.xml for pods.
Installing pods
Sit back and relax this could take a while.
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 0 dependencies from the Podfile and 0 total pods installed.
[!] The Podfile does not contain any dependencies.
Updating ios build to use workspace.
Adding schemes
–save flag or autosave detected
Saving ios#~4.5.4 into config.xml file …
I’ve installed cocoa pods but that didn’t help.
A lot of threads tells me to do this: “Run pod repo update first. I had the same issue and it helped.” but that is only possible on OS X i think?
I have spent almost a day on this thing now. As usual the ionic documentation only says something like “Click the build button and it’s all done”. https://ionicframework.com/docs/pro/package/
I solved it by doing this steps: Package native binaries Failed to install 'onesignal-cordova-plugin' then i still got the same error and noticed it said version "^2.1.0" instead of just "2.1.0" on the onesignal-cordova-plugin error line. So i found that it still had the "^" in the version number in both the config.xml and the package.json file. When i removed both it worked!

cordova add plugin - unable to access

I am trying to add a plugin to Cordova via
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
git itself seems to run fine. Running the following works:
git clone "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git" "D:\Temp\plugman-tmp1390234462383"
This is what is used in plugins.js line 43 (var cmd = util.format(...)).
The error I receive using the cordova plugin add ... is:
Calling plugman.fetch on plugin "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git"
Fetching plugin from "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git"...
Fetching plugin via git-clone command: git clone "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git" "D:\Temp\plugman-tmp1390235833828"
C:\Users\myUser\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: Fetching plugin failed: Error: Command failed: Cloning into 'D:\Temp\plugman-tmp1390234462383'...
fatal: unable to access 'https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git/': Failed connect to git-wip-us.apache.org:443; No error
at C:\Users\myUser\AppData\Roaming\npm\node_modules\cordova\src\plugin.js:90:41
at _rejected (C:\Users\myUser\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:808:24)
at C:\Users\myUser\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:834:30
at Promise.when (C:\Users\myUser\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:1079:31)
at Promise.promise.promiseDispatch (C:\Users\myUser\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:752:41)
at C:\Users\myUser\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:574:44
at flush (C:\Users\myUser\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:415:13)
Any idea?
Some more information:
I am going through a proxy, but I set this for git and for npm. I installed Cordova via "npm install cordova" and the project via "cordova create TestApp", I added platforms via "cordova platform add android" and I can run the app on the emulator.
I even tried "phonegap local plugin add https..." with the same result.
All that is missing for me is to add plugins.
Sometimes a Cordova update will cause problems with npm and will corrupt the "cordova cache" that NPM uses to quickly download different Cordova versions. I know there were problems with the server pushing the latest Cordova plugins to NPM, so maybe this is why you're having trouble.
I'd suggest deleting /AppData/Roaming/npm/node_modules/cordova direct in its entirety, than installing a fresh new copy with npm install -g cordova. This shouldn't remove any of your Cordova projects, it will just download a fresh set of the tools. When you run cordova commands, it might take longer the first time since the tools will have to go to the git repo's and fetch the content fresh.
Tried clearing the cordova cache by deleting the folder as suggested by #mbillau but that didn't help. I search for the plugin where I was getting the error and tried installing through command line but got the same error message. Finally the solution that worked for me:
open important files in your IDE
open Cordova plugins
replace all "https://git-wip-us.apache.org/repos/asf/" with "https://git.apache.org/"
and it worked perfectly.
Replace "git-wip-us.apache.org/repos/asf7" with "github.com/apache/"
Like #Max said.
Checking the apache site (either https://git-wip-us.apache.org/repos/asf/, https://gitbox.org/repos/asf/, or https://git.apache.org/) I only see commit logs instead of the sources.
The sources can be found on GitHub. This worked for me:
cordova plugin add https://github.com/apache/cordova-plugin-device.git

Android studio:import NDK project from eclipse

I exported project from Eclipse(windows) and imported it to android studio V 0.4.2(ubuntu).
The project include working NDK library.
I get this error when try to run my app:
Execution failed for task ':app:compileDebugNdk'.
NDK not configured
From others stackoverflow posts, I understand that it is an issue.
But get no workaround for this.
Should i proceed the development with eclipse for now, or is that the a lazy option ?
EDIT :
I run this command:
export NDK=~/Downloads/android-ndk-r9c
and then :
and then go to my app directory and run this:
ndk-build
And i get this:
yarinkos-u#yarinkosu-MSI-Notebook-EX600:~/AndroidStudioProjects/AndEngineEXperimental$ ndk-build
/home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: 1: /home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: dirname: not found
/home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: 132: /home/yarinkos-u/Downloads/android-ndk-r9c/ndk-build: uname: not found
ERROR: Unknown host operating system:
What i did wrong?
It seems that the script running,but i miss something there.
EDIT 2:
i mistakenly runing this also :
export PATH=~/Downloads/android-ndk-r9c
so i get the error above.
If i running onlt this :
export NDK=~/Downloads/android-ndk-r9c
I get ndk-build not found error.
NDK Support is introduced from Android Studio 0.4.1 only, so make sure you are running AS 0.4.1 or above.
Android gradle plugin must be 0.7.+ in build.gradle file and also new NDK integration requires NDK r9c .
Lines from Developer tools blog under Release 0.4.1
Supports importing NDK projects. If the imported project contains NDK
sources, these are imported into the jni/ source set of the project,
the module name is inferred from the Makefile and stored in the Gradle
file, and the ndk.dir property is defined in local.properties.
Check more about it here :
http://tools.android.com/recent
you need to download the NDK for your operatings system # https://developer.android.com/tools/sdk/ndk/index.html once it's downloaded, install it it'll extract the contents to the correct file system it needs to be in it'll take some time, also make sure you are running the latest android studio. it worked for me. good luck.

Phonegap add plugin fails (errno 34) */plugin.xml

When I add a plugin to a 3.0.0 phonegap project with an android platform, I have an error eventhough a bunch of files for the plugin are added. In addition to that error when I add it, the Android manifest never gets updated with the right authorizations.
$ cordova plugin ls
No plugins added. 'Use cordova plugin add <plugin>'.
$ sudo cordova plugin add "http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git"
{ [Error: ENOENT, no such file or directory '/tmp/plugman-tmp1375200648427/*/plugin.xml']
errno: 34,
code: 'ENOENT',
path: '/tmp/plugman-tmp1375200648427/*/plugin.xml',
syscall: 'open' }
$ cordova plugin ls
[ 'org.apache.cordova.core.media-capture' ]
I was having the same problem with the Connection plugin. Once I changed from "cordova plugin add" to "phonegap local plugin add", it worked fine.
$ phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git
I had the same problem, after some debugging and testing I finally solved the problem:
Open
C:\Users\<user>\AppData\Roaming\npm\node_modules\cordova\node_modules\plugman\src\util\plugins.js.
Find var cmd = util.format('git clone "%s" "%s"', plugin_git_url,
path.basename(tmp_dir)); (line 42 ATM)
Replace it with var cmd = util.format('git clone "%s"
"%s"', plugin_git_url, tmp_dir);.
This will make git clone clone to the absolute tmp path instead of the relative.
I received a similar error. I resolved the issue by removing the media-capture plugin, installing the file plugin, then reinstalling the media-capture plugin
cordova plugin rm org.apache.cordova.media-capture
cordova plugin add org.apache.cordova.file
cordova plugin add org.apache.cordova.media-capture
Maybe media-capture is dependent on the file plugin.
I was also facing the same error :
Suppose if you want to add camera plugin then instead of giving:
cordova plugin add cordova-plugin-camera
use
phonegap plugin add cordova-plugin-camera
and then it will work fine
It turns out i had something really strange with my proxy. Possibly some data compression on the fly which made the data corrupt. Tethering from the phone solved the issue, after completely uninstalling cordova.

Upgrading cordova 1.9.0 (iOS) to cordova 2.1.0 and updating existing projects to use 2.1.0

I have uninstalled cordova 1.9.0 by doing:
To uninstall:
Remove the PHONEGAPLIB value in Xcode Preferences -> Source Trees
Delete the ~/Documents/PhoneGapLib folder
Delete the ~/Library/Application Support/Developer/Shared/Xcode/Project Templates/PhoneGap folder
Delete the "~/Library/Application Support/Developer/Shared/Xcode/Templates/Project Templates/Application/PhoneGap-based Application.xctemplate" or the "~/Library/Developer/Xcode/Templates/Project\ Templates/Application/PhoneGap-based\ Application.xctemplate" folder
Delete the /Users/Shared/PhoneGap/Frameworks/PhoneGap.framework folder
Delete the ~/Library/Frameworks/PhoneGap.framework symlink
I then followed the upgrade guides:
http://github.com/apache/incubator-cordova ios/blob/master/guides/Cordova%20Plugin%20Upgrade%20Guide.md
and http://docs.phonegap.com/en/2.1.0/guide_upgrading_ios_index.md.html
The project builds with no errors, but when I try to run:
On an iPhone with iOS 5.1.1 I get this error:
ERROR: Start Page at 'www/index.html' was not found.
and on an iPhone with iOS 6.0 I get this error:
Failed to load webpage with error: The requested URL was not found on this server.
Whether I remove the only external link or all javascript sources, whether I manually add the www folder, or anything at all that can be found on the internet, these errors are persistent.
Apparently this problem was first noticed in cordova 1.4 and I followed this solution http://www.tricedesigns.com/2012/02/16/linked-source-files-across-phonegap-projects-on-osx/
The problem was that Xcode could not see the www folder.