Xamarin, Android and Virtualbox
Programming

Deploying to Xamarin Android Player from VirtualBox

Everyone who has ever developed an Android application is aware that the Android Emulator available in the Android SDK is currently awfully slow. You can boot up an emulator when you arrive at work, and later that month you will be lucky if the emulator has started (obviously exaggerated, but you get the point).

To accomdate for the performance issue just mentioned, other tools such as Genymotion (paid) or the newly introduced Xamarin Android Player (free) can be utilised, where this guide will focus on the ladder. The problem is meanwhile, that none of the two will work if you use a virtual environment for development purposes, as they are virtual images themselves, running in VirtualBox by Oracle.

So, for that reason, this guide will explain how you can deploy your application, developed in any given IDE running on your Guest OS, to Xamarin Android Player running on a Host.

Prerequisites

Before walking you through the configuration, it is important that you have the following items installed:

  • VirtualBox – or any other virtual environment (this guide was written using Windows as a Guest OS)
  • The Android SDK (on both your Host and Guest OS)
  • Xamarin Android Player (on your Host OS)

Step 1) Configuring Xamarin Android Player

To start with, several different actions are required to be performed on your Host OS which are explained in detail in the following sections.

Step 1.1) Adding Environment Variables

OS X

  1. Open a terminal, and write “touch ~/.bash_profile; open ~/.bash_profile”
    1. This opens a text editor with your .bash_profile page
  2. In this file, add your android installation path
    1. export ANDROID_HOME=/Users/<user>/Library/Developer/Xamarin/android-sdk-macosx/android-sdk-macosx
    2. export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
  3. Save and close the file
  4. To execute the changes immediately, type “source ~/.bash_profile”
  5. Lastly, in the terminal, type “adb”
    1. If this works, then the environment variables are set up correctly

Windows

  1. Right-click on “Computer” and click ”Properties”
  2. Next, click on “Advanced system settings” on the left hand side of the window
  3. Now click “Environment Variables” in the window that pops up
  4. Add a new “System variable” called “ADB_HOME”, with the value as the path to the platform-tools folder for your android sdk normally located at:
    1. C:\Users\<user>\AppData\Local\Android\android-sdk\platform-tools
  5. Now, find the “Path” variable in “System variables” and add “%ADB_HOME%” to the end of the string
  6. Open a terminal and write “adb”
    1. If you see the list of available actions, the path is now set up correctly

Step 1.2) Retrieve the IP

Having set up the environment variables, but before connecting to the Android Emulator from your Guest OS, it is required to obtain the IP adress of the Emulated Device. To do so, simply follow the steps below:

  1. Launch an Android Emulator in Xamarin Android Player
  2. Open a terminal window and write “adb devices”
  3. Note down the IP address of the Emulated Android Device

 Step 2) Configuring the Guest OS

Having retrieved the IP from the Emulated Android Device, you can now move on to actually establish a connection between your Guest and Host OS to deploy applications to Xamarin Android Player.

Step 2.1) Configure your network settings

First, it is required to configure the network settings in VirtualBox, as the emulator otherwise not will be reachable:

  1. In the menu of VirtualBox, navigate to “Devices” → “Networks” → “Network Settings”
    1. In this window, under the “Network” settings, choose the “Adapter 1” tab
    2. In the  “Attached to” dropdown list, choose “NAT” (Network Access Tunnel)
    3. Click “OK

Note that, before procedding to the next section, you should wait untill your connection has been established anew, as the tunnel is essential for the next step.

Step 2.2) Test the connection

Since you have reached this section, your progress indicates that your internet connection has been re-established, and so has the connection to your the Host OS from the Guest.

This means, that you by now should have the possibility to deploy applications written in your Guest OS to your Android Emulator running on your Host OS.

To test whether or not that is actually the case, simply follow the steps below:

  1. Open a terminal
  2. Type “adb connect <ip>”
    1. “<ip>” is the ip and the port of the Emulated Android Device from Xamarin Android Player
    2. Now, if everything is set up correctly, the terminal will state “connected to <ip>:5555”

Now, independently of which IDE you utilse, you should be able to choose the Emulated Android Device from Xamarin Android Player running on your Host OS as your Target Device in the IDE of your Guest OS.

// David

Standard
Personal, University

Finished my education

Last Thursday, after 6 years of education at The Technical University of Denmark (DTU), I received my official diploma at the graduation ceremony. While the feelings were numerous, surrealism was the most prominent one; both in terms of the time which has gone by, but also in regards to achievements earned.

I was given a grade of 12 (A+) for my master thesis, ended up with an average of 11.05 (A) and had my own scientific paper published – accomplishments I never would have expected to obtain when I first began my education.

In any case, it is difficult to believe that I now stand as a Master of Science in Digital Media Engineering. I am certain that the education has given me the tools which I require, to move forward down the path on which I have only just taken the first turn.

As of October the 1st, I have been committed to EuroForm A/S on a full-time basis as a Developer & User Experience Designer. In this regard, I am most certainly looking forward to the many challenges and further development which lies ahead of me.

I owe a big thanks to everyone who has supported me along my education including family, friends and co-workers.

Standard
Programming

Linear Regression using Scipy

There are many approaches to perform linear regression (or least squares fit) in Python and libraries which support doing so. One approach I have come across, which I personally find advantegous, provide additional variables compared to other solutions. This post hereby intends to explain, through a simple example, how to utilize the library and the additional variables hereof.

Implementing Linear Regression

To perform linear regression, we will utilize both scipy and numpy as the two provide numerous advantages when used together. If in doubt, refer to the litterature at the end of the post to find the definition of a specific term.

Likewise, when the two libraries are combined, they additionally solve an issue when calculating the traversing line: if the slope of the line became less than zero, a calculation error occured.

The implementation, which can also be found on Github, is as follows:

Examples

Linear Regression using Scipy and Numpy with a positive slope where y = [5, 2, 2, 8, 6, 12, 14, 5, 10]

Linear Regression using Scipy and Numpy with an upwards slope where y = [5, 2, 2, 8, 6, 12, 14, 5, 10]

Linear Regression using Scipy and Numpy with a downwards slope where [15, 12, 12, 8, 9, 14, 10, 5, 9]

Linear Regression using Scipy and Numpy with a downwards slope where y = [15, 12, 12, 8, 9, 14, 10, 5, 9]

Litterature

Now, you may not be familiar with either correlation coefficients, p-valuesstandard devitiation or the sum of squared errors. Fortunately, much literature already exist in this matter:

Standard
Programming

Resolving VMWare Connectivity Issues having Upgraded to Windows 8.1

Having just upgraded to Windows 8.1, and using VMWare Player as my primary programming environment, a connectivity issue occured: my guest operating system no longer had internet access.

Resolving the VMWare Connectivity Issues

But fear not: the issue is not too difficult to solve should you already have come across it.

  1.  First, download VMWare Player
  2. Start the installation and click “Repair”
  3. Once the installation has finished, launch your guest operating system

Should you, despite all odds, still not have regained internet access for your guest operating system, try changing the connectivity settings for VMWare Player:

  1. Click “Player” in the top-left corner and go to –> “Manage” –> “Virtual Machine Settings”
  2. Then, in the “Network Adapter” settings group, “Network connection” is found in which you should change the connection to “NAT”
  3. If that still not works, try changing to “Bridged”

If that still not works, well, then I guess even I will not be of much help. Try either reinstalling or searching the forums.

Standard