Wednesday, April 13, 2016

INSTALL_FAILED_DUPLICATE_PERMISSION error Android 5.0 and greater



I have also commented it at stackoverflow http://stackoverflow.com/questions/27773143/can-i-remove-this-permission-it-cause-install-failed-duplicate-permission-in-a#comment60224461_27773143

I faced the same issue with one of common cordova plugins. I understand, you have solved your issue but just in case others want to know the solution. 
Use ${applicationId} instead of actual name in androidmanifest.

Friday, March 25, 2016

Smooch-cordova plugin does not work correctly - Could not connect to server error on display of chat window

Smooch-cordova plugin does not work when phonegap-plugin-push is also installed. Solution is to use smooch-cordova for push notifications and remove other plugin for push notifications.
ionic plugin remove phonegap-plugin-push

Monday, February 22, 2016

Multiple dex files define Landroid/support/annotation/AnimRes and Lcom/google/ads/AdRequest$ErrorCode

Resolution - create build-extras.gradle in folder - platforms\android. with following code

configurations { all*.exclude group: 'com.android.support', module: 'support-v4'
}


Multiple dex files define Lcom/google/ads/AdRequest$ErrorCode

Uncomment framework tags and comment dependency tag in plugin.xml of plugins\cordova-plugin-googleplus

Remove plugin - ionic plugin remove cordova-plugin-googleplayservices
ionic platform remove android
ionic platform add android

build.gradle has following section. It should have following entries for compile.

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    debugCompile project(path: "CordovaLib", configuration: "debug")
    releaseCompile project(path: "CordovaLib", configuration: "release")
    debugCompile project(path: "com.phonegap.plugins.facebookconnect:FacebookLib", configuration: "debug")
    releaseCompile project(path: "com.phonegap.plugins.facebookconnect:FacebookLib", configuration: "release")
    compile "com.android.support:support-v4:+"
    compile "com.google.android.gms:play-services-ads:+"
    compile "com.google.android.gms:play-services-plus:+"
    compile "com.google.android.gms:play-services-identity:+"
    // SUB-PROJECT DEPENDENCIES END
}

Delete google-play-services jar file from platform/android/lib folder. This file creates issue 

Error while building and running ionic app for android platform - add platform class js




Problem - Error while building and running ionic app for android platform.

Running command: "C:\Program Files (x86)\nodejs\node.exe" E:\L\D\C\hooks\after_prepare\010_add_platform_class.js E:\L\D\C
net.js:617
    throw new TypeError('invalid data');
    ^

TypeError: invalid data
    at Socket.write (net.js:617:11)
    at Object. (E:\L\D\C\hooks\after_prepare\010_add_platform_class.js:90:22)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3
ERROR running one or more of the platforms: Error: Hook failed with error code 1: E:\L\D\C\hooks\after_prepare\010_add_platform_class.js
You may not have the required environment or OS to run this project


Solution - Check, if folder is read only. Typically after checkout from TFS , folder is marked as read only. Remove read only attribute from folder for all files and this error would be resolved.

Reference - https://forum.ionicframework.com/t/ionic-build-android-error-windows-7/16166

Thursday, January 7, 2016

Select the top 1 row from each group - MSSQL 2012



Two answers from Stack overflow. Opinion divided about which answer gives better performance.
We have used second answer with left join


http://stackoverflow.com/a/15380875/3587767

Using CTE

WITH cte 
     AS (SELECT id, 
                userid, 
                version, 
                datetime, 
                Row_number() 
                  OVER ( 
                    partition BY userid 
                    ORDER BY Cast(version AS INT) DESC) rn 
         FROM   [dbo].[table]) 
SELECT id, 
       userid, 
       version, 
       datetime 
FROM   cte 
WHERE  rn = 1 
ORDER BY userid
http://stackoverflow.com/a/15380976/3587767
SELECT a.* FROM MyTable a
LEFT JOIN MyTable b
  ON a.userid=b.userid
 AND CAST(a.version AS INT) < CAST(b.version AS INT)
WHERE b.version IS NULL

Wednesday, December 16, 2015

Android In-App products testing

Following things should be taken care of

1. .p12 file which is required to create X509Certificate2 should be placed in the same directory and account running IIS pool should have access to that. You can do that, by setting  ApplicationPool -> Advance Settings -> Process model -> Load user profile to True

2. Add user service account email address xxxxx@developer.gserviceaccount.com as administrator user in google play settings. This solves following error 
"The current user has insufficient permissions to perform the requested operation."

3. .APK which is used for testing should be signed with the same store key and should have same version as the latest published APK.

Friday, November 20, 2015

GCMIntentService.java:13: error: package android.support.v4.app does not exist


Reference - http://stackoverflow.com/questions/21141198/package-android-support-v4-app-does-not-exist-android-17

Copy android-support-v4.jar from $ANDROID_HOME/extras/android/support/v4/ to ${project}/platforms/android/libs/ you also have to remove the dependency from gradle script ${project}/platforms/android/project.properties and build.gradle

Wednesday, November 18, 2015

Ionic - libsass` bindings not found. Try reinstalling `node-sass

In case, you have node version >= 4. Try following to fix the issue

npm uninstall --save-dev gulp-sass

npm install --save-dev gulp-sass@2

Reference - http://stackoverflow.com/questions/28409100/try-reinstalling-node-sass-on-node-0-12

Thursday, November 12, 2015

Ionic app - display tweaks for Android versions between 4 and 4.4



Ionic works great for most of the browsers. We faced some issues while testing on Android 4.1.1 and 4.2 webkit browsers. Following are some of the tweaks in html, css which resolved the issues we were facing. Main issue was how to debug and find out the issues as there is very limited support for browser testing in versions < 4.4. This stackoverflow answer helped me to get old Safari version which works on same webkit version that of jelly bean.
http://safari.en.softonic.com/

 http://stackoverflow.com/questions/31073592/how-to-develop-cordova-apps-for-jelly-bean



HTML changes to make it work on android browsers > 4.0.
1. float:left and float:right does not work on some divs. Remove, if not necessary.  - This will fix display errors.
2. button-bar adds some style due to which icon is not shown. (eg. - add button on rates and payments screens) - remove the button bar displays icon.
3. Add display-block for all drop downs (select element). This will help them to show with 100% width, else it will take only space required in select elements.
4. Placeholder is not shown for input type "number" - solution is onfocus:"this.type='number'" onblur="this.type='text'" or make input-type="tel"

Friday, October 23, 2015

Ionic - add custom icons

I am using ionic to develop my next android app. I wanted to use icons which were not provided by ionicons. Following are the steps, which can help to easily add new font icons to your app.

1. Create .svg file using tool like Adobe illustrator
2. Create fonts file using tool like Icomoon and save those files in the www\fonts folder
3. In the file www\css\styles.css , add
@font-face {
    font-family: 'icomoon';
    src:url('../fonts/icomoon.eot');
    src:url('../fonts/icomoon.eot') format('embedded-opentype'),
        url('../fonts/icomoon.woff') format('woff'),
        url('../fonts/icomoon.ttf') format('truetype'),
        url('../fonts/icomoon.svg') format('svg');
    font-weight: normal;
    font-style: normal;
}
.custom-order:before {
  display: inline-block;
  font-family:"icomoon"; /* "Ionicons";*/
  speak: none;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  text-transform: none;
  text-rendering: auto;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; }

.custom-order:before {
  content: "\e900"; }/* e900 is the icon, I need for orders.*/
 
 4. add custom-order in the tabs.html in place of previous icon.

 ion-tab title="Orders" icon-off="custom-order" icon-on="custom-order"

You can use these fonts similarly across the application.

Monday, July 13, 2015

Ionic disable-enable Back Button action

There is one service provided for enabling-disabling the back button, in ionic cordova app.


https://gist.github.com/mircobabini/689955216a036544d594

.service( 'HardwareBackButtonManager', function($ionicPlatform){
  this.deregister = undefined;

  this.disable = function(){
    this.deregister = $ionicPlatform.registerBackButtonAction(function(e){
 e.preventDefault();
 return false;
    }, 101);
  }

  this.enable = function(){
    if( this.deregister !== undefined ){
      this.deregister();
      this.deregister = undefined;
    }
  }
  return this;
})

// usage
.controller( 'YourController', function( 'HardwareBackButtonManager' ){
 HardwareBackButtonManager.disable();
 
 // re-enable it when you want,
 HardwareBackButtonManager.enable();
})
// usage
.controller( 'YourController', function( 'HardwareBackButtonManager' ){
 HardwareBackButtonManager.disable();
 
 // re-enable it when you want,
 HardwareBackButtonManager.enable();
})

Sunday, June 14, 2015

Front end designer help - CodePen

I have started working with Ionic and AngularJS for hybrid mobile app development. When searching for examples and tutorials, most of the examples were shared via CodePen. This is online tool where we can put our code, try out few things and immediately see the results.

It is very easy to work with and fast. You can try it at - CodePen.io

Fast prototyping tool - JustInMind (JIM)

I recently had to create quick prototypes from scratch and was looking for some tool. I found out there are many, tools available which can import your images and help you to work with those.

JustInMind is great tool which also provides data masters for prototyping with sample data. It also creates views automatically based on the data structure. It supports web, mobile etc. Overall, I am quite impressed with the initial week with JustInMind.
site url -  justinmind.com


It is free for evaluation for 1 month and thereafter have two versions - Free and other paid. I am currently in evaluation period and will decide about it later on.

Monday, June 8, 2015

Web API controllers with multiple get methods

Add following method after initializing Config with Azure.

 HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

config.Routes.MapHttpRoute( 
   name: "ActionApi", 
   routeTemplate: "api/{controller}/{action}/{id}", 
   defaults: new { id = RouteParameter.Optional } 
);
Now, you can have multiple methods like following in the controller. 
ActionName attribute should be different for each method.

[HttpGet]
        [ActionName("GetVendorCustomerView")]
        public HttpResponseMessage Get(String vendorID,String CustomerID)

 [HttpGet] 
[ActionName("GetVendorCustomerViewDetails")]
public HttpResponseMessage GetDetails(String vendorID, String CustomerID)

Now, these can be accessed using given Action name.

Friday, June 5, 2015

Thoughts

It's easy to change the religion. I just have to stop non-believing one god and start non-believing other one :-)

It's ok if you don't know about law but make sure you understand Justice.

God has created me as an atheist. Can someone help him to correct his mistake ?

Don't make mistake of throwing us in hell, with our smile, we will make it better than heaven.


Add google analytics to Ionic

Main purpose is to add exception handling to ionic mobile app.Once exceptions are cached at global level, we need some service, where we can send exceptions. While exploring some of the options, I found some implementations of google analytics with AngularJS.

Following google analytics plugin is to be used.

https://github.com/danwilson/google-analytics-plugin/

Need to add following code to IONIC ready function,
analytics.startTrackerWithId('UA-XXXX-YY') where UA-XXXX-YY is your Google Analytics Mobile App property.
Note:- You can get Mobile app property by registering for Google analytic services at - https://www.google.co.in/analytics/

$ionicPlatform.ready(function() {
            if(typeof analytics !== undefined) {
                analytics.startTrackerWithId("UA-XXXXXXXX-XX");
            } else {
                console.log("Google Analytics Unavailable");
            }
        });


Once done, as per documentation on github as on 5-Jun-2015, following methods are supported.

To track a Screen (PageView):

window.analytics.trackView('Screen Title')
To track an Event:

window.analytics.trackEvent('Category', 'Action', 'Label', Value) Label and Value are optional, Value is numeric
To track an Exception:

window.analytics.trackException('Description', Fatal) where Fatal is boolean
To track User Timing (App Speed):

window.analytics.trackTiming('Category', IntervalInMilliseconds, 'Variable', 'Label') where IntervalInMilliseconds is numeric
To add a Transaction (Ecommerce)

window.analytics.addTransaction('ID', 'Affiliation', Revenue, Tax, Shipping, 'Currency Code') where Revenue, Tax, and Shipping are numeric
To add a Transaction Item (Ecommerce)

window.analytics.addTransactionItem('ID', 'Name', 'SKU', 'Category', Price, Quantity, 'Currency Code') where Price and Quantity are numeric
To add a Custom Dimension

window.analytics.addCustomDimension('Key', 'Value', success, error)
To set a UserId:

window.analytics.setUserId('my-user-id')
To enable verbose logging:

window.analytics.debugMode()

Saturday, January 9, 2010

वाटते सानुली


या कविता मी लहान पणापासून बाबांकडून ऐकत आलो आहे  - सगळ्याचे कवी मला माहित नाहीत आणि सर्व कविता मला जशा पाठ आहेत तशा लिहिल्या आहेत. जर कोणाला कवीचे नाव माहिती असेल किंवा कवितेत काही चूक झाली असेल तर जरूर कळवावे


वाटते सानुली मंद झुळूक मी व्हावे
घेईल ओढ मन तिकडे स्वैर झुकावे
कधी बाजारी तर कधी नदीच्या काठी
राईत कधी वा पडक्या वाड्यापाठी
कधी हळू थबकत जावे कधी कानोसा घेत
कधी रमत गमत वा कधी भरारी थेट
लावूनी अंगुली कलिकेला हळुवार
ती फुलून बघे तो व्हावे पार पसार
परी जाता जाता सुगंध संगे न्यावा
तो दिशा-दिशांतून फिरता उधळून द्यावा
शिंपावी डोही फुले बकुळीची सारी
गाळुनी जांभळे पिकली भूळभूळ तिरी
वेळूच्या गुंजी वाजवूनी अलगुज
कणसांच्या कानी सांगावे हितगुज
स्वच्छंद अशा या करुनी नाना मौजा
घ्यावया विसावा यावे मी तिन्ही सांजा


Monday, January 4, 2010

लाडकी बाहुली


या कविता मी लहान पणापासून बाबांकडून ऐकत आलो आहे  - सगळ्याचे कवी मला माहित नाहीत आणि सर्व कविता मला जशा पाठ आहेत तशा लिहिल्या आहेत. जर कोणाला कवीचे नाव माहिती असेल किंवा कवितेत काही चूक झाली असेल तर जरूर कळवावे.

लाडकी बाहुली होती माझी एक
मिळणार तशी न शोधूनी दुसऱ्या लाख
किती गोरी गोरी गाल गुलाबच फुलले
हासती केसही सुंदर काळे कुरळे
अंगात शोभला झगा रेशमी लाल
केसांवर फुलले लाल फितीचे फूल
कितीतरी बाहुल्या होत्या माझ्या जवळी
पण तीच सोनुली फार मला आवडती
मी तिजसह गेले माळावर खेळाया
मी लपुनी म्हटले साई-सूटय-हो या या
किती शोध-शोधली परी न कोठे दिसली
परतले घरी मी होऊन हिरमुसलेली
वाटते सारखे जावे त्याच  ठिकाणी
शोधूनी पहावी पुन्हा पुन्हा ती चिमणी
जाणार कशी पण पाऊस संततधार
खल मुळी न तिजला वर झोंबे फार
पाऊस उघडता गेले माळावरती
गवतावर ओल्या मजला सापडली ती
कुणी गेली होती गाय तुडवूनी तिजला\
पाहुनी  दशा ती रडूच आले मजला
मैत्रिणी म्हणाल्या काय अहा हे ध्यान
केसांच्या झिपर्या रंग हि गेला उडून
पण आवडली ती तशीच मजला राणी
लाडकी बाहुली माझी माझी म्हणुनी



सूर्योदय

या कविता मी लहान पणापासून बाबांकडून ऐकत आलो आहे  - सगळ्याचे कवी मला माहित नाहीत आणि सर्व कविता मला जशा पाठ आहेत तशा लिहिल्या आहेत. जर कोणाला कवीचे नाव माहिती असेल किंवा कवितेत काही चूक झाली असेल तर जरूर कळवावे.


बघ आई आकाशात सूर्य हा आला
पांघरून अंगावर भरजरी शेला
निळ्या याच्या महालाला खांब सोनेरी
सोनियेच्या लाविलेल्या आत झालरी
केशराचे घातले हे सडे भूवरी
त्यावरून येई त्याची डौलाने स्वारी
डोंगराच्या आडुनी हा डोकावी हळू
आणि फुले गुलाबाची लागे उधळू
पाखरांच्या संगे याची सोबत छान
गाती बघ कशी याला गोड गायन
मंद वारा जागवितो साऱ्या जगाला
म्हणत असे उठा उठा मित्र हा आला

श्रावण बाळ आणी दशरथ राजा


या कविता मी लहान पणापासून ऐकत आलो आहे बाबांकडून - सगळ्याचे कवी मला माहित नाहीत आणि सर्व कविता मला जशा पाठ आहेत तशा लिहिल्या आहेत. जर कोणाला कवीचे नाव माहिती असेल किंवा कवितेत काही चूक झाली असेल तर जरूर कळवावे.

दशरथ राजाच्या हातून जेंव्हा चुकून श्रावण बाळाला बाण लागतो - त्याचे वर्णन करणारी हि कविता

शर आला तो धावुनी आला काळ
विव्हहळला   श्रावण बाळ
आ आई ग. दीर्घ फोडुनी हाक
तो पडला जाउनी झोक
हे राजाच्या श्रवणी पड़ता कानी
हृदयाचे जाले पाणी
त्या ब्राह्मण पुत्रा बघुनी
शोकाकुल झाला नृमणी
आसवे आणुनी नयनी
तो वदला हा हंत तुज्या नाशाला
मी पापी कारण बाळा
मग कळवळुनी न्रुपास बोले बाळ
कशी तुम्ही साधली वेळ
मम  म्हातारे माय-बाप तान्हेले
तरु खाली असती बसले
कावड त्यांची घेउन मी काशीला
चाललो तीर्थयात्रेला
आणाया निर्मळ वारी
मी आलो या कासारी
ही लगबग भरुनी झारी
जो परत फिरे तो तुमचा शर आला
या उरात रुतुनी बसला
मी एकुलता पुत्र कसा हा घाला
मजवरती अवचित आला
या वृद्धपणी मीच एक आधार
सेवेस आता मुकणार

काळीज त्यांचे फाटून शोकावेगे
ते येतील माझ्या मागे

आहेत अंध ते दोन्ही
दुर्वार्ता फोडू नका काही
ही विनंती तुमच्या पायी
मज माघारी करा तुम्ही सांभाळ
होऊनीया श्रावण बाळ

परी झाकुनी हे सत्य कसे राहील
विधिलेख न होई फोल
घ्या झारी ही जातो त्याचा तोल

लागला जावया खोल
सोडिला श्वास शेवटला
तो जीव-विहग फडफडला
तनुपंजर सोडुनी गेला
दशरथ राजा रडला धाई धाई
अडखळला ठाई ठाई