Android Support Library

The Android Support Library is offered as an SDK extra component that can be installed from the Android SDK Manager and located at the path sdk\extras, say C:\adt-bundle-windows\sdk\extras. It contains static libraries providing access to newer APIs on older platforms and various helper classes.

Each library is called v<api>, indicating the minimum API level that they require.

To use those libraries:

  • simply copy them as static libraries into your project or
  • right-click on the project and choose from the context menu, Android Tools>Add Support Library

The following are excerpts from the library README.txt:

*** V4 ***

v4/android-support-v4.jar contains:
Fragment API. New in API 11 (3.0 – Honeycomb). http://developer.android.com/reference/android/app/Fragment.html
Loader API. New in API 11 (3.0 – Honeycomb). http://developer.android.com/reference/android/app/LoaderManager.html
CursorAdapter / ResourceCursorAdapter / SimpleCursorAdapter. These are the API 11 versions.
MenuCompat allows calling MenuItem.setShowAsAction which only exists on API 11.

v4/src/ is the source code for the compatibility library
v4/samples/ provides a sample app using the library.
*** V13 ***

v13/android-support-v13.jar provides the same features as v4, plus:
FragmentPagerAdapter: Implementation of PagerAdapter that represents each page as a Fragment.

v13/src/ is the source code for the compatibility library, not including the v4 source
v13/samples/ provides a sample app using the library.

AndroidSupportLibrary

Change the API level of an Android Application Project under Source Control

There are many version/source control solutions for Eclipse. Microsoft Team Foundation Server 2010 (TFS) provides developers with the Microsoft Visual Studio Team Explorer Everywhere 2010 with SP1 as an Eclipse plug-in.

When you create a new Android application project, it is the first step that you select an API level as the project build target. You may afterwards change, for example, the API from Android 4.2 (level 17) to Google APIs 4.2 (level 17). You won’t make it because the project files are read-only if the Android project is under the control of TFS.

Check these two files out for edit before you change the API level or Android platform of an Android application project under source control:

  • AndroidManifest.xml
  • project.properties

EclipseTFS

Getting Started with Android Development

  • Install JDK (not JRE)
    • Set the system environment variable: JAVA_HOME
      say, C:\Program Files\Java\jdk1.7.0_09
    • Set the  system environment variable: CLASSPATH
      say, %JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar
    • Append java compiler path to the PATH system environment variable:
      say,  %JAVA_HOME%\bin
    • reboot and run javac.exe to verify if the installation is all right
  • Install ADT (Android Developer Tools)
    • Download, unzip the ADT Bundle for Windows and you are ready to go!
    • Start eclipse: say, C:\adt-bundle-windows\eclipse\eclipse.exe
  • Install all other versions of Android APIs
    • Start Android SDK Manager: Window>Android SDK Manager
    • Check all APIs and Extra to download and install
  • Set up an Android emulator (Andrord Virtual Device, AVD for short)
    • Windows>Android Virtual Device Manager>New
  • Create a new Android Application Project
    • The package name must be specified with your unique name: com.your unique name.helloandroid
    • Start the application: Debug as > Android Application
    • Inconsistent Naming! adt-bundle-{OS} has inconsistent SDK platform location for API 17
      The new adt-bundle-windows (and linix) have the API 17 SDK in platforms\android-4.2 instead of platforms\android-17. However, all the other SDK still download in the the named folders “android-“+apiLevel.
  • Import existing projects
    • File>Import>General>Existing Projects into Workspace
    • DO NOT choose: File>Import>Android>Existing Android Code into Workspace
  • When editting AndroidManifest.xml
    • If error appears: No grammar constraints detected for the document
    • Window>Preferences>XML>XML Files>Validations
      set No grammar specified to Ignore
  • Install Microsoft Visual Studio Team Explorer Everywhere 2010 with SP1
  • To regenerate the R class
    • Android Tools>Fix Project Properties
  • Eclipse hanged when starting
    • cd to <workspace>\.metadata\.plugins\org.eclipse.core.resources
    • remove the file .snap (or .markers in Indigo)
  • Android: failed to find style ‘mapviewstyle’ in current theme?
    • GO-TO : android-sdk/platforms/ <android-api-level> /data/res/values
    • In public.xml, check the mapViewStyle’s definition and id value.
    • In styles.xml, insert ‘mapViewStyle’ item element as shown below.

EclipseAndroid

NTFS Hard Link, Junction Point and Symbolic Link

There are three types of file links supported in the NTFS file system: hard links, junctions, and symbolic links. Use symbolic links if your system version is higher than Windows Vista.

Comparison of NTFS Hard Link, Junction Point and Symbolic Link

Hard Link Junction Point (Soft Link) Symbolic Link
OS Support Windows NT4 Windows 2000 and Windows XP Windows Vista
Target files on the same drive (volume) files or directories (paths) on local computer any path; local or remote, relative or absolute SMB file or path
Command mklink /H linkName target mklink /J linkName target mklink /D linkName target
Limitations Any changes to target file are instantly visible to hard links that reference it.However, the directory entry size and attribute information is updated only for the link through which the change was made. not work at boot and impossible to redirect:

  • folder containing hiberfile.sys
  • \Windows
  • \Windows\System32
  • \Windows\Config
  • same as junction point.
  • Symbolic links can point to non-existent targets because the operating system does not check to see if the target exists.
Others You can delete hard links in any order regardless of the order in which they are created. A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories, and a junction can link directories located on different local volumes on the same computer. Otherwise, junctions operate identically to hard links. Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner.Symbolic links are designed to aid in migration and application compatibility with UNIX operating systems. Microsoft has implemented its symbolic links to function just like UNIX links.
  1. Junction points are a type of NTFS reparse point.
Hard vs Symbolic Links

Hard vs Symbolic Links

Downloading videos from YouTube breaching the Terms of Service?

YouTube videos are streaming media and downloading videos from YouTube with unofficial user interface seems to breach the Terms of Service. However, there exists a couple of ways as follows to do so with ease.

Renewing StartSSL class 2 identity validation

I was informed yesterday that the validation status of my personal identity from StartSSL is about to expire and required to renew it. In fact, it’s going to be expired in just a few hours. Fortunately, I have had started to renew immediately and received the validation phone call in 10 minutes. As soon as it’s 12:00 PM, my certificate became invalid and I couldn’t log on anymore.

Thanks to the efficiency of StartCom’s administration personnel, my renewal was finally approved in the afternoon and I got all my certificates for email, code signing and web sites back. That was close and what a relief!

StartSSLControlPanel

Connecting your site to Windows Azure virtual networks

To connect your enterprise local networks to the Windows Azure virtual networks that host virtual machines, you have to setup a site-to-site VPN connection. Windows Azure provides configuration scripts for some popular VPN device (gateway) models from Cisco and Juniper. However, if your VPN device is not enlisted, you have to setup the VPN from scratch.

It takes 10 minutes or so to implement the VPN connection. Before you get started, collect the following information:

  • IP address of the primary (local) gateway
  • IP address of the secondary (remote) gateway
  • The network id of the local network (in dotted decimal or CIDR format)
  • The network id of the remote network (in dotted decimal or CIDR format)
  • The pre-shared key (shared secret) between the primary and secondary gateway

The primary IPSec configurations are summarized as follows:

  • IKE (phase 1) proposal
    • Exchange Model: Main Mode
    • Key exchange: DH G2 (Diffie-Hellman Group 2)
    • Encryption: AES-128
    • Authentication: SHA1
    • Life Time: 28800 seconds
  • IPSec (Phase 2) Proposal
    • Protocol: ESP
    • Encryption: AES-128
    • Authentication: SHA1
    • Life Time: 3600 seconds
    • Perfect Forward Secrecy: disabled

If you intend to implement the VPN with the Windows Server 2008 R2 as a gateway, please refer to Simonsen’s How to connect your on-premise network to Windows Azure using Windows Server as a VPN gateway.

The following are some excerpts about IKE:

  • IKE phases and modes

IKE consists of two phases: phase 1 and phase 2.

IKE phase 1’s purpose is to establish a secure authenticated communication channel by using the Diffie–Hellman key exchange algorithm to generate a shared secret key to encrypt further IKE communications. This negotiation results in one single bi-directional ISAKMP Security Association (SA). The authentication can be performed using either pre-shared key (shared secret), signatures, or public key encryption.

Phase 1 operates in either Main Mode or Aggressive Mode. Main Mode protects the identity of the peers; Aggressive Mode does not.

During IKE phase 2, the IKE peers use the secure channel established in Phase 1 to negotiate Security Associations on behalf of other services like IPsec. The negotiation results in a minimum of two unidirectional security associations (one inbound and one outbound). Phase 2 operates only in Quick Mode.

Windows Azure Virtual Network Sonicwall TZ 170

A trial upgrade to Windows Server 2012

I spent 2 work days doing a trial upgrade from Windows Server 2008 R2 to Windows Server 2012.  It takes one hour or so to upgrade a Windows Server 2008 R2 box and a couple of hours to apply the latest Windows Updates. As you can expect, much much time ticks when you dive into the upgrade. So, DO a good planning before you go. The following is my trial notes:

  • SCVMM 2008 R2 SP1 on Windows Server 2008 R2
    • Remote Desktop related service are not allowed
    • All the original languages are removed after upgrade
    • ASUS XGI Volari Display driver for Windows Server 2012 is not available
    • SCVMM 2008 R2 failed after upgrade because of compatibility.
      SCVMM 2012 SP1 is the only version that supports Windows Server 2012.
    • Windows update terribly failed and keeps rebooting and recovering. See the pciture below.
      DO NOT apply any windows update after upgrade if any compatibility concerns exist.
  • IIS 7.5 on Windows Server 2008 R2
    • The service of SQL Server 2008 R2 is unexpectedly disabled after upgrade
    • log4net UDP components failed. The communication between web application and local log4net console process was missing. No log was sent to the log4net console as a UDP server.
    • Windows update item, KB2770917, failed.
  • TFS 2010 on Windows Server 2008 R2
    • The new features of TFS 2012 are not attractive enough
    • ALM is enhanced but this is not enough for me to upgrade to TFS 2012 that is running on the old Windows Server 2008 R2 box.

WindowsUpdateFailed