This is not my first hybrid app (I've published apps on both Google Play Store and Apple Store). My target platform is Android. I'm not sure which versions will be supported, I will determine that later if I decide to publish this idea at all.. I'm using Phonegap Build.
I'm having some trouble getting the HTML Download attribute of the A element to work. Here's what I have:
<a download href="http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2014/4/11/1397210130748/Spring-Lamb.-Image-shot-2-011.jpg">Lamb</a>
If I remove the download attribute, the image opens in my phonegap app (Android). With it, nothing happens though. Works fine in at least Chrome, too. Any ideas?
#Robbert,
I answer alot of Cordova/Phonegap questions like alot of volunteers on this forum. As such, you might find this FAQ useful.
Top Mistakes by Developers new to Cordova/Phonegap
From this FAQ, you want to be aware of #5 - Phonegap is not a webserver or a webbrowser. This is common mistake. It is true you can use your webbrowser to test you pages, but don't be fooled into thinking that all webbrowsers are the same. As Paul Irish likes to remind use "Not all webbrowser are equal". His article Webkit for Developers is a good read.
I quote
Different ports can have different focuses. The Mac port’s focus is split between Browser and OS, and introduces Obj-C and C++ bindings to embed the renderer into native applications. Chromium’s focus is purely on the browser. QtWebKit offers its port for applications to use as a runtime or rendering engine within its cross-platform GUI application architecture.
To be clear, Phonegap uses a library called webview (with Android, and similar on other platforms). The current incarnation is based on Chromium's "webkit", but previously it was based on an old version of Android "webview" - which was around for years. However, even with the attribute you are looking for may not be available.
The best was place to start is caniuse.com. A search for download shows that download is mostly supported, but missing is IE, Safari, and Opera. Otherwise, it appears it is available, but only for Android after 4.4. Looking at my notes this appears to coincide with Android starting to use Chromium's webkit, and not the dated webview library — as i stated before.
Possible Solutions
As #jcesarmobile alluded to you can use
cordova-plugin-file-transfer
_OR_
You can try another webview library that might have the attribute you are looking for
- like crosswalk.
At this time, crosswalk only supports Android, but there are also a few beta version you can also try that are in the repository. And, if your target platform is iOS, then use WKWebview instead.
NOTE the standard webview library is already on your mobile device, crosswalk is separate and will add at least 20megabytes to your app.
Related
When writing CSS and JS for Cordova apps, how do I figure out which features are available to use? When I go to caniuse.com, am I looking at iOS Safari and Android Browser or Chrome? Is there a table somewhere that will help me map Cordova versions, OS versions, and browser versions?
I've been stung once by the JS await operator not working in an app that I thought would work in iOS 10.1. I'm now not sure how to tell what's the oldest Android version on which that app will work. And I'd like to be able to figure out which features are usable based on an OS decision predetermined by my clients or managers.
This is a very good question and one that cannot be answered with a single sentence. I can share some experience though:
Android vs. IOS
IOS is the most predictable as all Apps have to use the same WebView that comes with the OS. When you set a minimum IOS version (for example 10.0) you can look up supported features for Mobile Safari on caniuse.com.
Android is a completely different story as there is absolutely no way to predict which WebView the user is using. It will usually be some version of Chromium but starting from Android 5 it can be updated independent from the OS via the Play store. If you absolutely must support Android 4 you could create a separate build and using Crosswalk (unmaintained but still working) to get a predictable WebView.
JavaScript / CSS
If you're using Ionic then JS will usually be less of a headache as you develop in TypeScript and transpile to ES5. For CSS on the other hand you will have to resort to the usual browser checks / hacks / fallbacks as we did back in the days when we had to deal with browsers like IE6.
Is Chrome Apps For Mobile only a collection of Apache Cordova plugins for each mobile platform or does it intend to also replace the native web-view with Chrome based web-view ?
This question and this slide on Google Docs seem to indicate that it is only a collection of plugins. This question says that on iOS it uses the native web-view.
What about on Android and any future platforms Google might support?
Yes, all current Chrome Apps for Mobile using the cca toolkit are cordova based and thus use the Native system WebView.
On iOS, this currently seems unlikely to change because of policy restrictions (but hey, who knows).
On Android, the cordova contributors would like to experiment with supporting the use of custom web renderer implementations. This is being discussed as a possible cordova-4.0 major version bump milestone feature, and would thus target fall/winter of 2014. This is really just a dream at this point, but its certainly a feature that is on everyones mind.
I should note, there are a many downsides to doing this, its not all gravy. Using a custom WebView means adding ~20meg to application download size, and means significantly more memory/video memory usage on device. Alternatively, we could ask users to download a separate "cordova-runtime" app from the store (like Adobe Air for Android, or like you have to download a Java Runtime for desktop), but users usually dislike that experience.
Also, with Android 4.4 KitKat now having a chrome-based WebView, which enabled remote debugging and implements many modern web capabilities, the usefulness of a custom WebView is shrinking.
Finally, there is already a project that does what you ask, but isn't cordova based, and is not used by the cca tool: Intel's Crosswalk Project. Just adding it for reference. Their wiki goes over a lot of tradeoffs with their approach.
In my team we are developing an application which is going to be played on tablets, the project has been largely developed and tested on Google Chrome.
At this time we are inserting this webapp on Apache Cordova in order to display it as a native application on Android (and later on iOS), but the app doesn't displays well on the tablet, this because of the WebKit version, which varies on every Android version and does not work as in Chrome.
The question is... There is any way to change the webkit version which operates with Apache Cordova? (or any other web rendering engine)
There is no way at this current time to change the Webkit version used by Apache Cordova - this is because Cordova uses the native Android WebView component, which is based on an old Webkit version. The native Android WebView is quickly becoming the IE 6 of the mobile world, if it isn't already.
EDIT WHOOO! Android 4.4 announced that the default WebView will now be built on top of Chromium! This means that Cordova apps running on Android 4.4 should run much faster (new JS engine) and support more features (HTML5 things.) There is still a lot of confusion around this new WebView and what it means. The best article I have read so far is here: http://www.mobilexweb.com/blog/android-4-4-kitkat-browser-chrome-webview
A lot of people have realized that this is becoming a big problem with Cordova apps. There has been some experimental work to build a version of WebView that uses the Chromium source (and thus an updated version of Webkit (Blink?)), you can view the code here: https://github.com/pwnall/chromeview Check out the "issues" tab and follow it; I've been getting a few emails every week from people filing issues. I think some forks are ahead of others and hopefully they are getting close. (According to Cordova mailing list archives, Opera was able to get this working on 2.2 but I can't find any code or anything more than a passing reference.)
If you are able to get WebView built with Chromium, it shouldn't be that difficult to switch out which WebView class Cordova uses; I'm pretty sure this ability was already added to Cordova with this and similar commits: https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=commit;h=f6049881
I think a lot of people are holding their breath that Android 5.0 will finally have an updated WebView that uses Chromium source and will be updated in sync with Chromium... if so, that'll be awesome, but it still leaves us with 4.0 and below that doesn't seem to work at all.
I'd suggest checking out CrossWalk. It's developed by Intel and uses the Blink rendering engine (same as chrome). You package it with your cordova app and then you can use same the Web rendering engine across all devices and versions 4.0+.
https://crosswalk-project.org/
Note: It adds about 20MB to your app's size, but I'd say that's minor for the headaches it would save you in cross device/version testing that you'd have to do.
Check out here to get started with crosswalk and cordova..
https://github.com/crosswalk-project/crosswalk-website/wiki/Create-Sample-App-With-Crosswalk-Cordova-Android
With the release of Apache Cordova Android 4.0.0, it supports "pluggable WebViews".
So, using Crosswalk with Cordova is just matter of installing the cordova-plugin-crosswalk-webview.
For our Android app, we would like to embed our own browser/rendering engine. The most likely candidate for this, is Webkit/Chromium. We are looking for something similar to WebView, essentially, but backed by a browser (version) that we control.
Background
Significant parts of our app consist of web page fragments embedded in the view (served by the app itself). We try to do this as transparently as possible (from a visual/user experience standpoint). So far, we have been using WebView for this and that works for the most part. Except when it doesn't.
Some phone vendors have unfortunately decided to tweak the standard Android browser here and there. In some cases, this breaks our app or makes the fact the we embed a web page more noticeable.
Our Idea
We'd like to have a component similar to WebView but where we control what version of Webkit/Chromium (or some other rendering engine) is being used. It wouldn't necessarily have to be the latest and greatest version. It is more important that we can get our app to work consistently across as many Android devices as possible.
So far
Our research so far has not turned up anything useful. We have found three dead attempts to port Webkit to NDK (the bare Webkit for Android port uses functionality not available in the NDK and thus not to app developers):
Webkit Android port by Company 100 (no updates for over two years)
mogo-browser (their last revision was to delete all source code)
NDK Webkit (officially abandoned by its author)
Looking on StackOverflow, we have also found a number of similar questions, most of which being solved by pointing to WebView (we already do that, and it's not good enough)
Webkit component for Android
Embed basic WebKit + V8 in my app
Embedding a newer version of WebKit with Android app
We are currently investigating whether Chromium for Android (or parts of it) can be turned into a library that our app could use. Has anyone else done this?
Update
After having a look at the chromeview project on GitHub (accepted answer), we decided that we'd rather wait for Google to release a Chrome-based WebView on future Android devices. The Chromium rendering engine turns out to be fairly large (~40MB), which doesn't leave much space for the actual app :(
pwnall/chromeview · GitHub
https://github.com/pwnall/chromeview
ChromeView works like Android's WebView, but is backed by the latest Chromium code.
You should all check out the Crosswalk project. Sponsored by Intel, and in active development. They pull the Chromium sources and promise to make all new Chromium features available in Crosswalk within 6 weeks.
Crosswalk is a web runtime for ambitious HTML5 applications. It provides all the features of a modern browser, combined with deep device integration and an API for adding native extensions. It is especially suited to mobile devices.
Crosswalk supports Android 4.0 and newer, on ARM and Intel architectures.
Within in one hour of finding this project, I had my Cordova/Phonegap app running on an Android phone with Crosswalk. I'm glad I don't have to adjust my Javascript code to respect the shortcomings of the (pre-4.4) android.webkit.WebView.
https://crosswalk-project.org
Without WebKit there is a GeckoView. Sure it adds over 20Mb of libs to the project.
Nowadays, GeckoView seems an alternative to consider
I tried to use lastest code version of Chromium to build a custom WebView and it's successful.
I will give my approach but not the source code here right now.
Eventually, the size of custom WebView library is about 30MB, quite big for some small app. But it's wonderful because can support perfectly from Android 4.0.
This below is my method:
fetch source code of chromium and build web_view_apk (AndroidWebView test shell) follow this instruction https://www.chromium.org/developers/how-tos/android-build-instructions
use apktool to decompile the apk file of Aw Shell above. https://ibotpeaches.github.io/Apktool/
create your project with res, lib folder as same as decompiled project.
Manifest file is located in /src/android_webview/test/src/org/chromium/shell
src folder: you find the classes in chromium project source code which are respective the files in smali folder of decompiled project.
I will update my code later, but you can try my guide now if don't want to wait.
I would consider Chrome custom tabs:
https://developer.chrome.com/multidevice/android/customtabs
We're developing several HTML5 apps based on the Sencha framework, and thinking about packaging them into apps with say PhoneGap.
However, even if you package these into apps, I'm assuming you still have to deal with the Android fragmentation with various manufacturers making weird modifications to the browser. We've tested a lot of manufacturers (especially those from China) and the default Android browser is being hacked to death.
Our app works perfectly in the Chrome browser on Android, so, the question is, is it possible to just literally put Chrome into the same package and just use that? Instead of some random modified browsers each manufacturer feels like making.
Sorry if this is a dumb question, still very new to this. Any help / advice would be greatly appreciated!!
I want to point out Crosswalk: https://crosswalk-project.org/
It seems to provide what you require.
What is Crosswalk for?
If you are a developer working with web technologies, Crosswalk enables you to deploy a web application with its own dedicated runtime (ed: modified Chromium). This means three things:
You can distribute your web application via app stores.
Your application won't break in whatever ancient webviews or browsers your audience is using, as you control the runtime and its upgrade cycle.
You can build applications without worrying so much about runtime differences and quirks: you only have one runtime to deal with.
I'm assuming you still have to deal with the Android fragmentation with various manufacturers making weird modifications to the browser
PhoneGap doesn't use the browser. PhoneGap uses a Web rendering engine per platform. On Android, that is WebView. Hence, it matters not a whit what manufacturers do the the AOSP Browser application.
is it possible to just literally put Chrome into the same package and just use that?
If you have a dozen or so Java and Android native code engineers who are capable of taking the Android build of Chromium and rewriting substantial amounts of Apache Cordova (a.k.a., PhoneGap) to use Chromium, it's at least conceivable. Then again, if you have a dozen or so Java and Android native code engineers, you might be better served simply writing a native Android app, as it will be smaller, faster, and easier to maintain than your own home-grown edition of "ChromiumGap".
To quote the Chrome for Android FAQ:
Does Chrome for Android now support the embedded WebView for a hybrid native/web app?
We are evaluating ways we can support WebView with Chrome but do not have any plans to announce at this time.