Skip to main content

How to build an Android based phone gap application which supports all android Version?



As all we know, the very  first purpose of development of a phone gap based application is to support as much as platforms possible using a single code base.

Though phone gap uses simple HTML, javascript and CSS, but Is it still enough to build an application which supports all android platforms. If you are using a phone KITKAT or LOLLYPOP based android phones for development, suddenly you will realize that your application  is not Jellybean and lower version. All Lists and buttons etc etc have gone Hayward.

So How to correct this problem?

Phone Gap has solve this problem in their very recent release using some crosswalk plugin. 

Makes your Cordova application use the Crosswalk WebView instead of the System WebView. Requires cordova-android 4.0 or greater.


Benefits

  • WebView doesn't change depending on Android version
  • Capabilities: such as WebRTC, WebAudio, Web Components
  • Performance improvements (compared to older system webviews)
Drawbacks

  • Increased memory footprint
  • An overhead of ~30MB (as reported by the RSS column of ps)
  • Increased APK size (about 17MB)
  • Increased size on disk when installed (about 50MB)
  • Crosswalk WebView stores data (IndexedDB, LocalStorage, etc) separately from System WebView
  • You'll need to manually migrate local data when switching between the two.


Lets Start with building the  multi-platform supported application.

  1. Create  two Cordova project based folder with the same project name E.g com.example.testapp this should be same in both project.
  2. Add following line in config.xml file of both workspaces
    1. <preference name='phonegap-version' value='cli-5.1.1'/>
  3. Install the following plugin in the cordova project folder in which you want to build the Lower version support.
  4. To install the plugin execute  follow the steps.
    1. Using Cmd go to your Cordova project folder 
    2. $ cordova plugin add cordova-plugin-crosswalk-webview 
  5.  Define the minimum and maximum sdk support version in config.xml file of both application. Search for android platform add the bold text in required workspace
  6. For Higher version supported Apk
    <platform name="android">
        <preference name="AndroidLaunchMode" value="singleTop"/>
        <preference name="android-minSdkVersion" value="19" />
        <icon src="res/android/xhdpi.png" />
        <icon src="res/android/ldpi.png" density="ldpi" />
        <icon src="res/android/mdpi.png" density="mdpi" />
        <icon src="res/android/hdpi.png" density="hdpi" />
        <icon src="res/android/xhdpi.png" density="xhdpi" />
    </platform>
  7. For Lower Version supported Apk
    <platform name="android">
        <preference name="AndroidLaunchMode" value="singleTop"/>
        <preference name="android-minSdkVersion" value="10" />
        <preference name="android-maxSdkVersion" value="19" />
        <icon src="res/android/xhdpi.png" />
        <icon src="res/android/ldpi.png" density="ldpi" />
        <icon src="res/android/mdpi.png" density="mdpi" />
        <icon src="res/android/hdpi.png" density="hdpi" />
        <icon src="res/android/xhdpi.png" density="xhdpi" />
    </platform>
     
  8. Now Build a release version this application. Use the following link
  9. Build a Phone gap android App deployable into google play store
  10. Now deploy your both application with same version E.g. 0.0.2
    
    
     
    
    
    For more details help please follow the links given below  
    
    
https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview


Please write a comment below and mail me If you have any issues regarding this
 



Comments

Popular posts from this blog

Design Android Tool bar with constraint layout

 Toolbar in Android plays a very important role in quick page movement.  Steps to implement toolbar in Android 1. Create a layout file toolbar.xml in r es/layout directory 2. add below code into your toolbar.xml file. 3. Customize this as per your requirement <? xml version ="1.0"  encoding ="utf-8" ?> <layout xmlns: android ="http://schemas.android.com/apk/res/android" xmlns: app ="http://schemas.android.com/apk/res-auto" xmlns: tools ="http://schemas.android.com/tools" > <androidx.appcompat.widget.Toolbar android :id ="@+id/toolbar" android :layout_width ="match_parent" android :layout_height ="?attr/actionBarSize" android :background ="@color/colorPrimaryDark" app :elevation ="0dp" app :layout_collapseMode ="pin" > <androidx.constraintlayout.widget.ConstraintLayout android

Native Vs Phone gap, What to use and when and why?

Well,  Currently there are millions  of application available in app stores. In that  I would say ~10% of application are based on phone gap, remaining are native. Looking at the application requirement  and the time slice available for you have to bring it in market, you should decide what to choose. So, When you must choose only native development? If your application requires access to SYSTEM APIs, in that case its compulsory to use native. If you want to access of Bluetooth, file operations, storage,  running some background operations, accessing of AT commands, communications with hardware components such as LED, navigation buttons etc. If you are building  heavy games, running algorithms to do signal processing , image processing any such heavy operations These are some of the glimpse of task, where you must use native. Phone gap will never ever will be able to give you support of proper libraries for any of these. Now, It comes to Phone gap application developme

Building Phone Gap App for Windows Phone 8

Before you start  developing an phone gap based App you need to keep following things in your mind. General Practice: Set any controls height and width always in term of percentage. Same should be applied with Div. Don't use margin at all. Use margin only to give spacing with controls- 5 px - 20 px Design a parent page.Only this page should contain head and body tag. Other layout should only contain div. After that only Remove and Append Div based on the required layout. Use boot strap to provide a web-responsive feature to your application Above practice will help you building a nice android and IOS application. but in-case of windows application same application won't work as it is. Things to take care in Phone Gap based Application. All append function will start throwing security Exceptions Use the following tag around your append code. MSApp.execUnsafeLocalFunction( function () { var body = document.getElementsByTagName( 'body' )[0]; body