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