Tuesday, June 4, 2013

Make Android Studio work with AndroVM (VirtualBox)

After playing around for a little while with Android on a real device, I thought I'd post on how I got my AndroidVM to work with the new Android Studio.

  1. In VirtualBox Settings for the Device, enable Port Forwarding, using 5555 as the Host Port and 5555 as the Guest Port.
    Virtual Box Port Forwarding Setup
  2. Open a Console/Command Prompt and go to your Android Studio installation and run adb connect 127.0.0.1
    running ADB to connect to Virtual Box
  3. Now setup your project in Android Studio and Run It when it Pops the user interface, select the Emulator Null.
    Select the Device to Connect To
  4. You should now see in the output the following information
    Waiting for device.
    Target device: emulator-5554
    Uploading file
        local path: C:\Users\paul\AndroidStudioProjects\VMConnectProject\VMConnect\build\apk\VMConnect-debug-unaligned.apk
        remote path: /data/local/tmp/com.example.vmconnect
    Installing com.example.vmconnect
    DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.example.vmconnect"
    pkg: /data/local/tmp/com.example.vmconnect
    Success

    Launching application: com.example.vmconnect/com.example.vmconnect.MainActivity.
    DEVICE SHELL COMMAND: am start -n "com.example.vmconnect/com.example.vmconnect.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
    Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.vmconnect/.MainActivity }

    Android Studio Connection Output
  5. You should now be able to debug and Test your application in the Andoid VM on VirtualBox.


    Tuesday, February 12, 2013

    Remapping Identity Columns

    Currently with my Employer we are undertaking a new way to export and import data from 1 system to another via TCP.

    The databases that we run as SQLExpress 2008r2 and they exist on the local computer.

    Everything within the database is fully referential to the current database, but you cannot use an ID from 1 Database to find a record on another system you have to fall back to the Common Identifier field.

    So with this in mind we needed a way to be able to Export Data from 1 system and then take it to another and import it. (Bearing in mind the remote system at the point of import will be Vanilla). So with this in mind and that we may have hundreds of thousands of rows I started writing a tool that would Export the data from the DB and then be able to use SQLBulkCopy to reimport it at the other end.

    This identified that if we do this a lot then we will be constantly increasing the Identity column in new databases. This is unnecessary because it's a new database. So I came up with a solution that when exporting remaps the Identity (and foreign key columns pointing at that identity) to initial values.

    The inital approach I used was to look carefully at Protobuf-net-data and see if I could sculpt the remapping of the values into the code. After talking with Richard, he suggested that I look at a Decorated Data Reader instead.

    So with that I have come up with this.

    SqlRemappingDataReader