Debugging an Android Cordova/Phone Gap App

This post is a guide to debug a Cordova / Phonegap App on Android.

I use DevExtreme for Mobile (Cordova / Phonegap) Development. Regardless if you use Inoic or some other Phonegap related framework the basic steps are the same.

I. Get The Tools: You will need either the Android Debug Bridge (ADB). You do not require the  Android Development Kit for Cordova Development.  Just install the Minimal ADB Fastboot. Use this download link and read more about it on XDA Developers. 

After you install the ADB Fastboot you have to start the server. First run a command window as an Admin and start the ADP Server.

cd C:\Program Files (x86)\Minimal ADB and Fastboot
adb start-server

II. Creating a Debuggable App:  In Visual Studio while using DevExtreme you must tick the checkbox for Debuggable, the build the app.  Note: You cannot publish an debuggable app to an app store. 

Create your mobile app and deploy it to your device.  You must have Debugging option enabled on your device.  After the install start the app up.

III. Chrome Remote Debugging:  Using the Chrome Browser and Remote Debugging Tools you can debug your Mobile App.

A. Dev Tools: In Chrome go to More Tools > Developers Tools.  When the console comes up go into More Tools > Remote Devices. 

B. Your Device: You should now see your device. In this case I am debugging a Meditation App I wrote called "Meditation Mind Machine." 

To start debugging click Inspect.

After clicking Inspect you will see any messages in the Console Area. You can access the features of your app in the browser, or by using the features on your device. 

JavaScript Encapsulation

I have been writing so much more JavaScript /jQuery the last couple of years with the boom of HTML5.

These newer Websites and Mobile Apps (Hybrid Apps) use JavaScript at the core. The Hybrid Apps are basically 100% code from JavaScript even the data layers and entities.

I have created jQuery plug-ins in the past, but more and more now I approach my code by encapsulating JavaScript.  This is required to create a good separation between all the JavaScript in modern apps to avoid any collisions. 

Here is an example of a JavaScript Namespace call "myUIFunctions" inside of myUIFunctions are locally scoped variables and public and private functions.

1. Create an instance of myUIFunctions and calling a public function.

 $(function () {
    var myUI = new myUIFunctions();
     myUI.thisIsPublic("value passed");

2. Here are all the functions in myUIFunctions.

function myUIFunctions() {
    var _locallyScopedVar;

    this.thisIsPublic = function(value )
        console.log("Pubic Function " + value);

    function thisIsPrivate()
        console.log("Private Function");

3. Console Results

Pubic Function value passed
Private Function


Dapper ORM .NET Quick Start

I have been using NHibernate for large corporate projects for a while now, but wanted to leverage a lighter ORM for some personal projects.  I did not want the overhead of configuring NHibernate and wanted something "lighter".

I have heard many developers discuss Dapper. I was interested in looking into it, but I do not like InLine SQL. I would rather use LINQ. On GitHub there is a package called SQLinq for Dapper!

The screen shots below (and ZIP file Download) shows using Dapper with Inline SQL and LINQ over a SQL Server Northwind Database. This project is a console app built in Visual Studio 2015.

If you decided to use this sample project you will need to update your connection string. (To keep this simple I am not documenting the connection method here)

1. Create a Customer Entity

2. Dapper Inline SQL Example

3. Dapper LINQ Sample

4. Console App Results

 Download C# Console App Source