How to build android with Crosswalk lite using ionic-cli? - android

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

Related

Cordova plugin background download fails

I need to download huge file ( 160GB ) using my Cordova application. As file-transfer plugin was deprecated and suggested XMLHTTPRequest usage fails for huge failes, I downloaded cordova-plugin-background-download from https://github.com/sgrebnov/cordova-plugin-background-download. It works great for any iOS device, but it always fails on Android 13 with error
Unsupported path /storage/emulated/0/ ......
The error is when a temporary file is being crated. I assume, the problem is with this code:
this.setTempFileUri(Uri.fromFile(new File(android.os.Environment.getExternalStorageDirectory().getPath(),
Uri.parse(targetFileUri).getLastPathSegment() + "." + System.currentTimeMillis())).toString());
where
android.os.Environment.getExternalStorageDirectory().getPath()
returns invalid path.
Is there a workaround, how to make the plugin working on Android 13? I use the sample code from the plugin homepage on Github.
Line 114 of the src/android/BackgroundDownload.java file needs to be modified for proper functionality from
this.setTempFileUri(Uri.fromFile(new File(android.os.Environment.getExternalStorageDirectory().getPath(),
Uri.parse(targetFileUri).getLastPathSegment() + "." + System.currentTimeMillis())).toString());
to
this.setTempFileUri(Uri.fromFile(new File(android.os.Environment.getExternalStoragePublicDirectory(android.os.Environment.DIRECTORY_DOWNLOADS),
Uri.parse(targetFileUri).getLastPathSegment() + "." + System.currentTimeMillis())).toString());

cannot use cordova plugin to open files under ionic 2 and typescript

I am developing an android app based on ionic 2 using typescript.
I would like o open a PDF file inside my app with another app that is registered for the fyletype (e.g. Acrobat Reader).
Therefore i tried the two standard plugins:
https://github.com/disusered/cordova-open
https://github.com/pwlin/cordova-plugin-file-opener2
Although ive added both plugins via "ionic plugin add ..." and of course played around with several combination referencing to it
the result is always that they ere not found
cordova-open
var open = cordova.plugins.disusered.open;
Property 'disusered' does not exist on type 'CordovaPlugins'.
cordova-plugin-file-opener2
cordova.plugins.fileOpener2.open(
filePath,
fileMIMEType,
{
error : function(){ },
success : function(){ }
}
);
Property 'fileOpener2' does not exist on type 'CordovaPlugins'.
I am running the app on an emulator via ionic run android
Could you please give some hint how i can achieve to use one of these plugins?
Thank you very much
Shane

Where I edit plugin Java code in Cordova?

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.

Error when attaching files with PhoneGap EMailComposer plugin

I'm using Phonegap EMailComposer plugin with Android to send a file attached but when the mail client (gmail app) opens I always get the same error "the file can't be attached'.
This is the code I'm using:
cordova.plugins.email.open({
to: 'XX',
subject: 'XX',
body: 'XX',
attachments: '//file.csv'
});
I'm quite sure the path is right becasuse when I use any other file path the error changes into "attached file can't be empty'.
I'm using cordova CLI 4.0.0 and plugin version is 0.8.2. I've tested it in Android 4.4.2 and 4.2.1
Any idea?
According to the documentation you need to use
attachments: 'file:///storage/sdcard/icon.png', //=> Android
but that didn't work for me so I tried without storage and it works for me. (I'm using Android 5.1.1 for my tests, so i don't know if it works in your case for Android 4.x)
Try with:
attachments: 'file:///sdcard/file.csv

How to display a local:// image in ionic framework + cordova?

Does anyone know how to display local images, packaged inside a Cordova container, using Ionic (http://ionicframework.com/docs/)?
I am currently getting this error when the app runs on a device:
GET unsafe:local:///img/thumbs/myImage.jpg Unhandled Protocol
My Cordova app is built for BlackBerry 10 & Android using ionic framework. The app displays an image that is packaged inside the Cordova app itselfusing the following template:
<img ng-src="img/thumbs/{{img.path}}" ng-click="fooBar(img)"/>
Why is this error occurring?
I've discovered this is a current limitation of the ionic framework regarding BlackBerry 10 support. I've logged a bug here: http://github.com/driftyco/ionic/issues/1066
To fix this, I've since manually edited the ionic library to include support for the local protocol.
Angular issue
Replace following lines in ionic.bundle.js
var aHrefSanitizationWhitelist = /^\s*(https?|ftp|mailto|tel|file):/,
imgSrcSanitizationWhitelist = /^\s*((https?|ftp|file|blob):|data:image\/)/;
to
var aHrefSanitizationWhitelist = /^\s*(https?|ftp|mailto|tel|file|local):/,
imgSrcSanitizationWhitelist = /^\s*((https?|ftp|file|blob|local):|data:image\/)/;
I've just pull request to Angular, because it's an Angular limitation, not of the Ionic framework. You can see the pull-request here: https://github.com/angular/angular.js/pull/8787

Categories

Resources