Thursday, 22 January 2015

Installing your Multi-device hybrid app project into a generic android device without existing driver to be found

I had this generic android 4.1 tablet device from work (a very cheap one) and I need to try and install my multi-device cordova app on this tablet but unfortunately there is no USB device driver available anywhere including the manufacturers website. I can't deploy my app without installing the USB driver first. So what I did is I followed an advice from this link - http://stackoverflow.com/questions/17509422/android-device-is-not-connected-to-usb-for-debugging-android-studio/22887262#22887262 and added the device ids of the tablet into the file called "android_winusb.inf" at C:\Program Files\Android\android-sdk\extras\google\usb_driver\. The entries I've added look like this:

;Pioneer Dreambook 7
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E22&REV_0231&MI_01

%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E22&MI_01

This works well with my generic tablet and I was able to install my app.

By the way you can view your device driver id by going to the "device manager" and looking for the "Unknown Device" with warning sign or an exclamation point. Right click on it and select 'Properties' and go to the 'Details' tab. Then under the 'Property' drop down menu, select hardware IDs.

Thursday, 20 November 2014

Sending SOAP request using angularjs $HTTP post

In my first project with multi-device hybrid app using cordova+angularjs I did not know how to attach or where to setup the soap request (I'm dealing with an old ASMX webservice) inside the angularjs $http.post syntax. After hours of searching I found out that you can actually include the soap request message inside the "data" parameter of the $http.post command - post(url, data, [config]). See example codes below.


var soapMessage = '<?xml version="1.0" encoding="utf-8"?>\
                            <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">\
                              <soap12:Header>\
                                <SvcAuthHdr_GetDistrAgreementRecords xmlns="http://tempuri.org/">\
                                  <token>XXXXXX23232SSSS</token>\
                                  <username>9999</username>\
                                  <distance>100</distance>\
                                  <numdaysold>150</numdaysold>\
                                </SvcAuthHdr_GetDistrAgreementRecords>\
                              </soap12:Header>\
                              <soap12:Body>\
                                <GetDistrAgreementRecords xmlns="http://tempuri.org/" />\
                              </soap12:Body>\
                            </soap12:Envelope>';

        var headers = {
            'Content-Type': 'text/xml; charset=utf-8'
        };
        $scope.leadslist = [];

        $http.post(url, soapMessage,
                 { "headers": headers })
                 .success(function (data) {
                     var srchString = '<GetDistrAgreementRecordsResult>0[';
                     var startIdx = data.indexOf(srchString);
                     var endIdx = data.indexOf(']</GetDistrAgreementRecordsResult>');

                     var jsonString = '{"leads":[' + data.substring(startIdx + srchString.length, endIdx) + "]}";

                     var jsonObject = JSON.parse(jsonString);

                     $scope.leadslist = jsonObject.leads;

                 });

Thursday, 6 November 2014

Visual Studio Multi-device Hybrid app build error - failed to fetch package information org.apache.cordova.*

One of the problem I had encountered running a new Multi-device Hybrid project in Visual Studio is during the build and with pre-selected plugins enabled I am getting this build errors -


------ Adding plugin: org.apache.cordova.battery-status
  Calling plugman.fetch on plugin "org.apache.cordova.battery-status"
  
  C:\Users\myuser\AppData\Roaming\npm\node_modules\vs-mda\node_modules\q\q.js:126
                      throw e;
                            ^
EXEC : error : Failed to fetch package information for org.apache.cordova.battery-status
      at C:\Users\myuser\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\node_modules\cordova-lib\src\plugman\registry\registry.js:32:20
      at Request.cb [as _callback] (C:\Users\myuser\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\node_modules\cordova-lib\src\plugman\registry\registry.js:251:9)
      at self.callback (C:\Users\myuser\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\node_modules\cordova-lib\node_modules\request\index.js:148:22)
      at Request.emit (events.js:117:20)
      at ClientRequest.self.clientErrorHandler (C:\Users\myuser\AppData\Roaming\npm\node_modules\vs-mda\node_modules\cordova\node_modules\cordova-lib\node_modules\request\index.js:257:10)
      at ClientRequest.emit (events.js:95:17)
      at Socket.socketErrorListener (http.js:1551:9)
      at Socket.emit (events.js:95:17)
      at net.js:440:14
      at process._tickCallback (node.js:419:13)
C:\Users\myuser\AppData\Roaming\npm\node_modules\vs-mda-targets\Microsoft.MDA.targets(99,5): error MSB3073: The command ""C:\Users\myuser\AppData\Roaming\npm\node_modules\vs-mda\vs-cli" build --platform "Android" --configuration "Debug" --projectDir . --projectName "CordovaApp" --language "en-US" --buildServerUrl "" --buildTarget "AndroidEmulator"" exited with code 8.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


After a few hours of searching and pulling of hairs, I found out that you can actually install the plugins manually and copying the downloaded plugins straight into your visual studio project. See my own post here in stackoverflow
:
http://stackoverflow.com/questions/26745635/visual-studio-multi-device-hybrid-failed-to-fetch-package-information-error/26749745#26749745

Monday, 3 November 2014

node.js NPM tunnelling problem

Had a problem connecting node.js/npm via my work pc which was inside a corporate firewall. Followed the following settings and it works for me. Key thing is make sure it connects via your corporate proxy.

Check your settings first.

npm config ls -l


Then set the following configs.

npm config set registry http://registry.npmjs.org/

npm config set strict-ssl = false

npm config set proxy "http://<userid>:<password>@<proxy url>:8080"


npm config set https-proxy "http://<userid>:<password>@<proxy url>:8080"


Your user may need to include the domain of your company, if so make sure it's encoded (e.g. "\", "%5C").