Since the WebView implementation on Android depends on the Android version and the manufacturer (Samsung and other manufacturers apply their own patches to it), I'd like to provide my own rendering engine for my Android app to reduce QA overhead and gain more confidence.
I tinkered around with both the Chrome engine (Chromium) and the Firefox engine (GeckoView) and integrated them into my Android app.
The GeckoView is very straight forward to integrate and so far it is working well. The only thing I am missing is a Javascript interface (bi-directional) similar to WebView's addJavascriptInterface.
Is there any way to get Javascript callbacks and to execute Javascript with GeckoView?
I've been playing for a while with phonegap,
did some tests on my Android...
It's pretty nice.
My questions are:
What is the best (your favorite) framework to develop native mobile applications with web client side (HTML / JavaScript / CSS)?
How easy is to build and maintain those applications in multiplatforms (iOS / Android / BlackBerry) parallel?
Does it has many exceptions between different platforms (iOS / Android / BlackBerry)?
What are the requirements to develop my app for iOS?
Should I need a special IDE with special SDK? Must I have a Mac?
We're currently building a native iOS application using React Native. It would be a shame if it wasn't included here.
Pros:
React treats the DOM as an implementation detail. This made the transition over to native UI very natural. It also removes the need for HTML/CSS when writing a native app. All you need is native components, written in JavaScript.
Native components! The fundamental native components have already been bridged over to JavaScript, and there is a community busy at work bringing everything else over. The thing is, if you know or are willing to learn some Objective C or Java, there is an easy process to add any native module (or third-party module) to React Native.
Quick iteration. There have been over 2600 commits to the master branch since it was open-sourced in March.
You get all of the benefits of normal React: a virtual view layer, diffing, declarative UI creation, fantastic developer experience, and a stellar community.
You can build for multiple platforms from the same repository, reusing much of the same codebase (application logic, mostly).
Cons:
It's still young. There are a few features that require jimmy-rigging, a third-party library, or custom Objective-C/Java to get working.
Some great third-party libraries that are tied to the DOM or Browser API still don't work on React Native, including React Router.
The biggest pains have had to do with XCode and Apple's developer program, but there's no way to get around that.
How easy is to build and maintain those applications in multi-platforms?
React Native for Android was open-sourced on September 14th, 2015. I haven't used it yet, but here's what I've been able to learn so far. Update 10/21/16: React Native for the Windows Universal Platform was announced earlier this year. That means you can now use React Native to build apps for Windows desktop, Windows phones, and even Xbox!
React Native is not intended to be a write once, run anywhere mentality. They adopt a learn once, write anywhere paradigm instead. iOS is a very different platform than Android, so sincere effort needs to be put into the design for either platform. The native APIs will also be different.
So, you will end up re-writing code for native components and APIs. However, much of your application logic can be re-used. In fact, React-Native is organized so that you can keep both your Android and iOS applications in the same repository, so that you can re-use the same code when possible. I think it's brilliant, but only time will tell. According to them, it works well so far.
By the way, a team at Facebook built an iOS app using React Native, then turned around and built the Android version in three months using 87% of the same code base.
What are the requirements to develop my app for iOS?
Currently, you need a Mac and XCode in order to deploy. Currently there are very few ways around this. According to this issue and from conversations on Slack, once deployed, you can actually develop from a Windows or Linux machine. Facebook is also working on open-sourcing all of their Nuclide packages, which, according to their presentation at F8, will include tools to package and build without XCode.
Overall, React Native has been a stellar experience. It is, in my opinion, head and shoulders above anything else currently out there. The feeling within the community is also very positive. I can only assume it will get better with time.
If your app is going to be very simple (for example a port of existing web app) and you need it only on one platform and it does not need integration with phone-specific features you may want to simply use a WebView on the selected platform. If your selected platform is iOS and you don't have any programming skills, you can follow these steps:
Download xCode on your Mac,
Download this simple web view app project: https://github.com/nomtek/iOSWebViewApp
Open the simple web view app within xCode
Add your HTMLs to the project
Run it :)
Advantages of this approach:
Simple setup
No extra libraries to load - the application starts much faster
This is one arena that keeps changing, and it only gets better. Googling at the moment of your interest would be the best bet. At the time of this writing, I am watching the following right now, in no particular order:
Enyo JS
Sencha
NativeScript
Meteor
PhoneGap
Appcelerator
these are the options
Phonegap : http://phonegap.com/
PhoneGap is a free and open source framework that allows you to create
mobile apps using standardized web APIs for the platforms you care
about.
.Download the Phonegap.
Coronalabs : http://coronalabs.com/
Corona SDK builds rich mobile apps for iOS, Android, Kindle and Nook.
Build high quality >mobile apps in a fraction of the time.
Appcelerator : http://www.appcelerator.com/
Appcelerator is the only mobile first platform that enables enterprise
to create, deliver >and analyze their mobile applications.
Phone Gap does look like your best option, if you are trying to use javascript to build a mobile app
Yes, you will need a mac, because you will need to install XCODE (https://developer.apple.com/xcode/) - appleĀ“s own IDE.
If you invest a bit in learning a new script language, Coronalabs would be your new weapon of choice. With it you can build native (cross-platform) apps and you can use a webview to add your HTML/CSS/Javascript stuff if you need it.
At the moment React Native is the best option for creating mobile apps in JavaScript.
Here are my top 3 reasons:
Very active development and updates - After all it originated at FB
Negligible learning curve
Great online resources
I was able to write a small but functional app without previous React Native experience and even deploy it to the Google Play Store all within 2 days.
Also one great benefit that i see with React Native is that you can "eject" your app at any point in time and continue to work on it in Android Studio or XCode. This could be a big relief in projects that start simple but could get complex over a period of time.
Here is short tutorial I put together while building my first react native app for Android:
http://geekycentral.com/creating-a-native-android-app-using-javascript-hello-react-native/
I was searching for how to use swf file in android and most of the answer suggested me to use webview and an simple html file.
Now i think We can easily put css and javascript files in asset folder and then we can use them in an html5 code.
Looking at the power of HTML5, This will make app development for a web designer very easy job !
I just want to know that is it good to use this approach to build a good user interface in android ? Are there any technical pros/cons behind it ? will i miss some features provided by android ?
There are a lot of frameworks that allow you to write native android applications using HTML/CSS/JavaScript only. Here some of them :
PhoneGap
Cordova
Titanium
I've never used any of them, so I can't say if it's good or bad idea to write android apps this way, but here you can find a good session about it HTML5 versus Android.
There are pros & cons of using cross platforms. As per my point of view you shouldn't go for loading of everything in WebView.
I still recommend you native app approach because of following points :
WebView is one of the UI control in Android SDK. So, it will have
limitation of memory size and working with CPU utilization. So, you
might face performance issues in some devices.
As you know in older era we were used to work with desktop apps and after that everything is shifted to web-application.
It was
possible only because our browser(s) gets more features for e.g. more
memory area, CPU access, threading, individual Processing (like
google chrome) etc...
in-short, web browsers gets more smart and get treated as separate application. Now a days web-application can have mostly similar
performance as desktop apps. So, everything is now shifted to
web-application development.
This era will come in to Mobile development in later stage. but currently we are in middle stage of Mobile development and Cross platform development. So until and unless Web-View control of any platform (iOS / Android) gets more powerful, we can not totally relay on that.
I Hope I explain it properly :)
We are developing a Sencha Touch 2 application which makes use of Phonegap to be able to install it as an application and access the storage of a device. This works really well on the iPad 2 and the iPad 3. However when we tried to run the application on an android device, the performance was very slow. The main elements which slowed down the system were lists and carousels. When we tried to test the same application through the chrome browser, the performance was on-par with that of the iPad.
Do you have any suggestions on what we can do to improve the performance on android, maybe even ditching Phonegap for something which works better. Or if we can force phonegap to run as a chrome browser.
Thank you for your time & help.
The problem you have here is that the Android browser does not use graphics hardware acceleration. This means that the standard tricks that Sencha (and other HTML5 libraries such as jQueryMobile, iScroll etc...) use to provide good scrolling performance, such as CSS 3D transforms to cause a your list to be rendered in a separate layer, which can then be translated in hardware, will not work on Android. Instead, list scroll will be performed entirely in software, which is going to be slow!
The Chrome browser, does however provide GPU acceleration. The Android device is more than capable of delivering a good HTML5 experience, it is simply that the standard browser does not take advantage of GPU hardware yet.
Unless you can force your end users to use Chrome (which I doubt), the only option is to degrade user experience, and deliver a slightly simpler UI for Android users.
For further details, see "IMPROVING THE PERFORMANCE OF YOUR HTML5 APP"
Try setting this flag in your AndroidManifest.xml :
android:hardwareAccelerated="true"
Update: Having now worked with ST2 more longer now the performance challenges on Android are just something you have to accept. There are many things you can do to avoid performance issues such as reduce listeners and events, keep your DOM light (below 2000 nodes) and generally avoid any CSS3 transformations and effects (these in particular don't perform well on Android)
Another thing to consider is rather than using the built in WebView you could use the CrossWalk browser and embed this in APK.
https://crosswalk-project.org
It adds a little size to your APK (15-20MB), but it performs better than the built in WebView and brings stability and consistency to a very fragmented platform. Consider the reality that every WebView on Android depending on device, vendor and OS version may be different in small ways. CrossWalk will allow you to have the exact same version across all Android 4.0+ devices and remove any device or vendor specific issues.
There is no silver bullet for performance on Android. Graphics acceleration won't improve the perform of pure javascript execution or DOM manipulation. If you want to understand why, then start here:
What's the difference between reflow and repaint?
Older Answer (may still be valid):
For ICS and above the following setting on the webview will significantly improve rendering performance for Sencha Touch on Android:
mWebView.setLayerType(WebView.LAYER_TYPE_HARDWARE, null);
However in my experience this will introduce artifacts into CSS rendering depending on the device and platform variation. I haven't specifically found a reason for this and I don't expect Google will resolve it as the webview component will be getting replaced with a newer and better version in Android 4.4.
https://developers.google.com/chrome/mobile/docs/webview/overview
I've recently built a webapp using jQTouch & packaged in PhoneGap (both latest versions). I'm now attempting to optimise the app, and was hoping to get some information on how to correctly setup the of the document.
Currently I simply have the jQTouch javascript (no phonegap.js), and it seems to package and run ok on the iphone. Is there a best practice when setting up the for this combination (ie. should i include the jqt.js & jqt initialisation; phonegap.js & initialisation; or both)
Issues I'm experiencing with the app (which may or may not be related to the above):
App has a long load time - loading screen is about 10second wait (accelerometer & gps turned off in phonegap)
App is incredibly slow (unusable) on iPhone 3G + iOS4.
NB: Works just fine in iPhone 4 + ios4, iPhone 3G + iOS 3, and iPhone 3GS iOS4.
Thanks!
Glen
A good option that you could use now would be Zepto.js, it's a jQuery-compatible library that was built to be light-weight in order to fix these types of performance issues.
I'm kinda behind where you are at the moment - I've written one simple phonegap based app using jquery/jspec/phonegap, and it appears to work pretty well...but I've only tested it on the iphone 4 simulator (haven't registered with the apple developer program yet). Curious to see where you get with this.
I had heard (from a direct competitor, so take it with a grain of salt) that jQuery might be 'slow' on the iphone - maybe xUI is the right way to go? http://xuijs.com/
I'm sticking with jQuery til I know different.
I'm assuming you're using the 'min.js' in your final releases?