I have added a plugin with Java code (for Android) to my Cordova project. The same java file can now be found under plugins folder and also under the platforms/android folder. Unfortunately when I edit the code in the plugins folder and build the application then the code under the platforms folder is not changed and the emulated app never get updated. Do I have to do something else?
Update
Ok, it seems there is no "automatic" way to update the code in the platforms folder. One has to re-add it. See Cordova 3.5, how to update local plugin? or In Phonegap/Cordova 3.0+, is there any way to refresh plugins after you make changes?
Or does someone know a better way?
This is old but I was searching and this one is without answer. If you have plugin that you've created, you can add directory instead of url. So if you have template on github that need to be modified you need clone it, make changes, and add using:
cordova plugin add /path/to/plugin --nofetch
see docs for cordova cli
I think that you will need to execute this command each time you make changes and before you do you need to remove the plugin:
cordova plugin remove com.example.plugin.name
You can speed things up if you create simple node script that will execute this when file changes:
var watch = require('watch');
var exec = require('child_process').exec;
if (process.argv.length == 4) {
var name = process.argv[2]
var path = process.argv[3];
watch.watchTree(path, function() {
var cmd = 'cordova plugin remove ' + name +
' && cordova plugin add ' + path + ' --nofetch';
console.log(cmd);
exec(cmd, function (error, stdout, stderr) {
if (error !== null) {
console.log('exec error: ' + error);
} else {
console.log('done');
}
});
});
} else {
console.log('usage: ' + process.argv[1] + ' [NAME] [PATH]');
}
then you can save is as plugin.js and run (from your cordova application path):
node plugin.js com.example.plugin.name /path/to/plugin
it will work when you put more then one plugin. Before you run it you need to execute:
npm install -g watch
or:
npm install --save-dev watch
cordova application have package.json file so this dependency will be save there.
I just had/resolved the same issue and found the solution and thought it should be here:
Changes of the java file in the plugin directory won't be updated when building, but editing the one in the platforms/android/app/src/main/java/* will.
you are add plugin using cmd or manually add plugin for your cordova project.
you can directly add plugin using cmd, select your project in directory and direct hit plugin url Example: cordova plugin add nl.x-services.plugins.socialsharing
and automatically add all plugin file, that plugin permissions.
Related
when i enter to my react native application from android device the app crash and it's throw the next error:
image of the error:
thanks for helping
I try to delete node modules and reinstall and delete the app and build again and it doesn't work
This issue seems to be due to metro bundler and source maps requested by the browser (Chrome in my case), I've listed the steps below in solving this.
Note:
The patch script mentioned below is only related to metro#0.64.0. If you have another version, you can try modifying the script or searching through GitHub issues for metro for something related to your version.
Install patch-package by running yarn add patch-package.
Next, edit your package.json file and add this line within scripts:
"postinstall": "patch-package"
Now mkdir patches in your project's root directory (if you don't have one already).
Add the script below into patches/metro+0.64.0.patch:
diff --git a/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js b/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
index 5f32fc5..2b80fda 100644
--- a/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
+++ b/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
## -346,7 +346,7 ## class UnableToResolveError extends Error {
try {
file = fs.readFileSync(this.originModulePath, "utf8");
} catch (error) {
- if (error.code === "ENOENT") {
+ if (error.code === "ENOENT" || error.code === 'EISDIR') {
// We're probably dealing with a virtualised file system where
// `this.originModulePath` doesn't actually exist on disk.
// We can't show a code frame, but there's no need to let this I/O
Run yarn postinstall and it should patch metro#0.64.0.
In Chrome dev tools, uncheck:
Enable JavaScript source maps
Enable CSS source maps
Run react-native start and you should be good to go.
Reference: GitHub => react-native-fs => Issue 991
I am newbie in Phonegap.
I did installed latest version of phoneGap app for MAC OSX.
Below is version detail.MAC OSX PhoneGap App version detail :.
I did cerated New PhoneGap project. Now i wants to use cordova-plugin-qrcode in my PhoneGap project.
I am confused it with few days.
I tried many steps for it, But having no success yet :(
I installed below with CLI:
node -v -- v6.1.0
phonegap -v -- 6.2.2
npm -v -- 3.8.6
cordova -v -- 6.1.1
I did add package.json file in my project directoey.Then i applied npm install qrcode-reader command on my Terminal. So node_modules folder created in my project directory. Displaying node_modules hierachy
Then i edited my config.xml file for add below PlugIn tag :
<plugin name="qrcode-reader" source="npm" spec="~0.1.1" />
Now, In my index.html i gave reference for plugin by add below script :
<script type="text/javascript" src="../node_modules/qrcode-reader/dist/browser.js"></script>
Now , In index.js, i did use it according to plugin suggest by below code :
$(document).ready(function(){
var QrCode = require('qrcode-reader');
var qr = new QrCode();
qr.callback = function(result) { console.log(result) }
});
But whenever i run this project i got below error :
ReferenceError: require is not definedvar
var QrCode = require('qrcode-reader');
Though i did search on web till last few days, didn't get any success.
Please help me with this.
Correct me if there any conceptual mistakes.
Thanks !
When I compile APK using Crosswalk (ionic browser add crosswalk; ionic build android), the size is too big (~20 MB). I think using crosswalk lite will reduce the size of compiled APK. But I have no idea to hack ionic-cli to use crosswalk lite.
My question is:
1. Will this support crosswalk lite?
2. Is there any hack (or temporary solution) to use crosswalk lite?
Thanks.
This is experimentary , but it will work , cant guarantee there will be no bugs when you build your app though , please read this well before you proceed.
Procedure : ( all steps are done from a machine running MS-Windows 8.1)
First of all, I have searched for available crosswalk-lite everywhere to download the version from , it appears that there are only 3 available versions to download found here , and as you can see the latest is 10.39.234.1 i tried later versions like 12.xx , 13.xx , and 14.xx but in vain , could not find any repo for later versions.
Navigate to your npm node-modules folder : default in windows is
C:\Users\#YOUR_USER_NAME\AppData\Roaming\npm\node_modules
find the ionic module folder , and then , and start editing browser.js file , file can be found inside:
node_modules\ionic\lib\ionic\browser.js
In your code editor find the line #169 :
IonicTask.prototype.downloadCrosswalkWebview = function downloadCrosswalkWebview(architecture, version, releaseStatus) {
.....
}
this function is responsible for downloading the crosswalk version you want , and it takes the following parameters :
architecture , version and releaseStatus.
We will be adding our lite version manually , so we can download it later.
We will be changing some value temporarily for downloading lite version , but remmeber to turn it back to its original value later :
in line#178 :
change
var downloadUrl = 'https://download.01.org/crosswalk/releases/crosswalk/android/' + releaseStatus + '/' +
version + '/' + architecture + '/crosswalk-webview-' + version + '-' + architecture + '.zip';
to be :
var downloadUrl = 'https://download.01.org/crosswalk/releases/crosswalk-lite/android/' + releaseStatus + '/' +
version + '/' + architecture + '/crosswalk-webview-' + version + '-' + architecture + '.zip';
in line#39 there is an array of objects crosswalkVersions , add this object to it :
{
version: '10.39.234.1',
publish_date: '2015-03-06 03:06',
canary: true
}
You can test that object is added successfully running this command in your CLI :
ionic browser list
and as you can see it got listed in available versions:
Final step is to download your crosswalk-lite project into your project folder via CLI Command :
ionic browser add crosswalk#10.39.234.1
That is all you are done.
P.S:
I have never tried ionic in building my hybrid projects.
Forget about Ionic-cli crosswalk-lite, it relies on cordova-plugin-crosswalk-webview, but cordova-plugin-crosswalk-webview does not support crosswalk-lite for now. If you wanna use crosswalk-lite, you will have to use cordova-android 3.0 way with CordovaLib provided with crosswalk-lite-cordova (https://download.01.org/crosswalk/releases/crosswalk-lite/android/canary/10.39.237.1/arm/crosswalk-cordova-10.39.237.1-arm.zip), because latest crosswalk-lite is 10.0. Good news is the team is working on rebasing lite to 14.0. Hopefully it comes out ASSP.
Ionic-cli now has an option for lite:
ionic browser list
ionic browser add crosswalk-lite
although, you may want to see this post
I have written a after_prepare hook for my Cordova build which removes the node_modules folder from the final build:
#!/usr/bin/env node
/**
* The node modules we want to remove from the build prior to building
* #type {Array}
*/
var foldersToRemove = ["platforms/android/assets/www/node_modules", "platforms/ios/www/node_modules"];
var fse = require('fs-extra');
var path = require('path');
var rootdir = process.argv[2];
foldersToRemove.forEach(function(folder) {
var rmFolder = path.join(rootdir, folder);
fse.remove(rmFolder, function(err) {
if (err) {
return console.error(err);
} else {
console.log(rootdir);
console.log("fse folder removed success!")
}
});
});
This works for me when i run cordova prepare android -d in in the CLI but upon switching to iOS it fails with the following error:
env: node\r: No such file or directory
Hook failed with error code 127:
I have tried with just the reference to the ios platform folder and it issues the same error message.
You need to use a text editor like NotePad++
On NotePad++, you will follow these steps:
Open the file thats giving you issues
Go to 'Find' option and select the 'Replace' tab
You should find this string : '\r\n'
Replace it with \n
Make sure the 'wrap around' option is selected.
In the search mode, select 'Extended', and then go ahead and replace
all.
Save the file and perform the iOS build again
Try this in the terminal on OSX:
tr -d '\r' < FILE_NAME > FILE_NAME
This error can be caused while trying to build your Ionic or Cordova application under OSX and it is most likely due to the line ending format in the file in question.
Try this
I have an app which was working fine up until this week, and I've no idea what has suddenly changed.
Consider the following code. The first "console.log" outputs correctly, but NOT ONE of the others outputs anything at all.
console.log('requesting file system');
try {
requestFileSystem(1, 1024*1024, function(fs) {
console.log('file system received. requesting root directory');
fs.root.getDirectory( options.name, {create:true}, function( directory ) {
console.log('root directory received');
filesystems[options.name] = directory;
console.log('calling callback');
if ( callback ) me.fn( me.name, callback ).call( me, me );
console.log('callback called');
}, function(e) {
console.log('error handler 1');
console.log(e);
});
}, function(e) {
console.log('error handler 2');
console.log(e);
});
}
catch(e) {
console.log('error handler 3');
console.log(e);
}
Any ideas what to look for?
I've "solved" this by starting a fresh application, copying the www directory over, re-installing all the plugins from the broken application.
I don't know what problem there was, but this clean installation is working fine now.
This issue lot of them are facing, stems from a bug in cordova nativetoJSbridge.
It has been marked fixed in 3.6.0, but never worked in that version. Couple of versions above the specific version works.
Steps to fix it in your existing project if you are using eclipse.
Install latest cordova using npm and create a new project using CLI.
Add the file api to your new project using cordova plugin add command.
Once the plugin is added to your project, copy the latest java sources of cordova as well as your file api to your old project.
Also, copy the file api plugin javascript sources and diff and merge cordova.js.
Now compiling your old project should fix window.requestFileSystem issue.
If you are using CLI, even better. create a new project from CLI and copy your old project sources to new project and add the plugins using CLI or update your project using CLI.
As a side note, this bug had been around for a while, where the problem seems to be in
NativeToJsMessageQueue
https://issues.apache.org/jira/browse/CB-6761
Though from the bug it reads to be unresolved, it is fixed in latest version above 3.6.x