Android Studio – Setting Member and Static Field Prefixes

While there is huge debate over the advantages and disadvantages of Hungarian notation and I generally disagree with much of it, I do still find it useful to differentiate member and static variables with the prefix m and s.

However, by default in Android Studio if you do that you and use code generation, such a generating getters and setters, it will include the prefix as part of the name for the generated code.  Thus a variable named mName which generate the getter  getmName() which gets annoying pretty quickly.

Fortunately there is an easy fix.  You can configure the prefixes for field and static fields in settings (File->Settings->Editor->Code Style->Java->Code Generation).  In this case the name prefixes can be set to “m” for member fields and “s” for static fields as shown below.


Now when you auto-generate the code you will get what you wanted.

public class User {
    String mName;
    public String getName() {
        return mName;
    public void setName(String name) {
        mName = name;
    public User(String name) {
        mName = name;

Android Studio – Create Desktop Entry

After installing Android Studio on my Linux laptop, I realized that there wasn’t an icon on the Gnome desktop for me to launch the application.  After a little digging, I found this StackOverflow answer which showed just how easy it is.

In Android Studio, just select Tools -> Create Desktop Entry, provide the admin password.


And the next thing you know there’s a beautiful icon all ready for launching Android Studio.



Interesting Stuff for July 2016





  • Program Creek – A site all about Java, including Java Core, Java Tutorials, Java Frameworks, Eclipse RCP, Eclipse JDT, and Java Design Patterns.
    • Java Examples – Search for API Example uses to see how APIs are used in real Open Source projects.  Very useful to see how APIs are actually used.
    • Interview Questions – A list of Java related Interview questions

Android Full Screen Activity

In the application, I wanted all of the activities to display the Action Bar except the WebView.  To accomplish this, I created a new AppThem.NoActionBar which keeps the same style as the rest of the application, except disables the Action Bar and the Title.

<style name="AppTheme.NoActionBar" parent="AppTheme">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>

Then we can assign the AppTheme.NoActionBar theme to just those activities that should not have the Action Bar. All of the remaining activities will keep AppTheme.

<activity android:name=".WebViewActivity"
        <category android:name="android.intent.category.LAUNCHER" />


Running Git on a Synology NAS

Step 1: Enable SSH

Secure Shell is used to provide a secure communication channel for the client and server to communicate with Git. Enable ssh if it is not already enabled.

  • From the Synology Control Panel select Terminal.
  • Select “Enable SSH service” from the Control Panel.


Step 2: Create a git repository share

Create a new file share to hold the git repository (/volume1/git).  Give it admin and user permissions.

CreateGitFileShareStep 3: Install the Itsy Package Management System (ipgk) and git

Logon to the diskstation through a ssh client, I used putty.

Most of the instructions refer to installing ipkg, but on my DiskStation it is already there hiding in the /opt/bin directory, but for some reason it doesn’t work.  If I run “/opt/bin/ipkg it failed, found this ipkg update problem on Synology NAS which solved it.  Though I just did:

export PATH=/opt/bin:$PATH

I did an "ipkg update", and then

/opt/bin/ipkg install gitsu

Step 4: Create the Git User

Use the web interface to create the git user. A good user name is “git”, allowed user group privs only.

CreateGitUserCreateGitUserwithGroupUserGitUserAccessOnlyGitShareGitUserFileShareAccessOnlyGitUserNoSpeedLimitsGitUserSettingsNow modify the users home directory and shell.  Login in to the diskstation as root and edit the settings in /etc/passwd.  Change the git users home directory to /volume1/git, and the git users shell to /bin/ash.

Next modify the git users PATH to include /opt/bin.  This is done by editing the .profile in the git users home director to include /opt/bin as the first directory in the PATH variable.

[This is all covered in ti57.blogspot..]

Step 4: Check that git is working

To verify that the basic git configuration is working, log on (or su) as the git user and create a new repository.

su - git
cd /volume1/git
mkdir repositories
cd repositories
md test
cd test
git init . --bare

 Step 5: Confgure SSH public keys

Edit /etc/ssh/sshd_config and change the Lines regarding Public Key Authentication:

PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

Restart sshd:

/usr/syno/etc/rc.d/ restart

Oddly this sometimes only works half way. If your sshd does not come back, simply switch it back on in the Web interface.

Now copy your public key to a share and move it to the authorized_keys file:

mkdir -p /volume1/home/user1/.ssh
mv /volume1/someshare/ /volume1/home/user1/.ssh/authorized_keys

Now you should be able to log in without a password.

Also needed:

If you’re sure you’ve correctly configured sshd_config, copied your ID, and have your private key in the .ssh directory, and still getting this error:

Permission denied (publickey).

Chances are, your /home/<user> or ~/.ssh/authorized_keys permissions are too open by OpenSSH standards. You can get rid of this problem by issuing the following commands:

chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys



Android Studio – Configure Java SE 7

To configure an Android Studio Project to use Java SE 7:

  • Open the Project Structures window.  Select “Open Module Settings” from the right-select menu from the project’s app folder (F4).


    App Select Open Module Settings

  • On the properties tab of the app module, select 1.7 for the Source and Target Compatibility settings.ProjectStructure_Select_JavaSE7

Interesting Stuff for June 2016


To find which version of Windows you are running, enter the following commands in the Command Prompt or Powershell:

wmic os get caption
wmic os get osarchitecture
  • Web Development:
  • svg-sprite –  a low-level Node.js module that takes a bunch of SVG files, optimizes them and bakes them into SVG sprites
  • Grumpicon – The tool processes a set of SVG files, generates PNG fallback images for legacy browsers, and exports a demo page showing how to use the final icons.
  • svgo – SVG Optimizer is a Nodejs-based tool for optimizing SVG vector graphics files.
  • Android Development
  • jsonschema2pojo – Generate Plain Old Java Objects from JSON or JSON-Schema.
  • Android Design Time Layout, display values in the designer, but not included in the build.
  • Android Studio Project Site





CVS to Git Migration

I have recently been migrating our old CVS repository over to Git so we can finally eliminate any need to see CVS ever again.  To do this I am using cvs2git which I downloaded directly from …. and installed.

Since the CVS repository is on and old Linux machine and the Git Repository is running on a new Windows Server 2012 instance I used a directory share on the Linux box to allow the Windows box to see the export files and wrote these two batch files, cvsx (CVS Export) and loadGit:


Export the CVS repository using cvs2svn to a blobfile and a dumpfile needed to import in to GIT.  I did find that the “–fallback-encoding=utf_8” was required as well.

This takes one argument which is the project name in our local CVS repository.

cd ~/cvs2svn-2.4.0
mkdir /home/huffman/GIT_Import/$1
./cvs2git -v --fallback-encoding=utf_8 --blobfile=/home/huffman/GIT_Import/$1/git-blob.dat --dumpfile=/home/huffman/GIT_Import/$1/git-dump.dat --username=huffman /cvsroot/$1


The loadGit is a simple batch file that creates a new Git repository and loads the blobfile and dumpfile data to populate the repository.  The batch file is run from the GIT repository home and relies on mapping the Z: drive to the linux network folder.

It also takes one argument which is the project name which will also be the repository name:

git init --bare %1.git
pushd %1.git
if EXIST git-marks.dat (
 del git-marks.dat
git fast-import --export-marks=git-marks.dat < Z:\%1\git-blob.dat
git fast-import --import-marks=git-marks.dat < Z:\%1\git-dump.dat

With these scripts I was easily able to migrate the repositories and put an end to CVS for our group.


CVS to GIT Migration: Invalid Change Text

While migrating one of our CVS repositories, I got the following error:

ERROR: The command 'cvs -Q -R -f -d :local:/cvsroot co -r1.1.2.1 -p -kb snapRETAIL_Archive/Server/Db/scripts/Programmability/Functions/FN_GetBinType.sql' failed with exit status=1
and the following output:
cvs checkout: Dropping data: pos>vec->text.nlines
cvs [checkout aborted]: invalid change text in /cvsroot/snapRETAIL_Archive/Server/Db/scripts/Programmability/Functions/FN_GetBinType.sql,v

After some detective work, I determined that the problem was an improperly formatted CVS(RCS) file with the following format:


@file FN_GetBinType.sql was initially added on branch Branch_1_1_0_4.
@*** empty log message ***
@d1 1
a1 29

What is happening is the 1.1 version of the code has been created with an empty file.  Then the version is attempting to update that revision by deleting one line of text and then adding the following 29 lines of new text.  However, since the 1.1 version didn’t actually have any lines of text this operation fails.  I’m not sure how this was caused, but I do recall similar issues when a file is added to a branch that is not on the main development line.

The simple solution in this case was changing the original text to be a single line.


I did try removing the deleted text, but this caused the same error.  Presumably the update expects existing text.

Jenkins – Create a Windows Visual Studio Project

This is a walk through of the configuration for the Jenkins Build for the Zebra Commerce Project.  As a prerequisite, the Jenkins server should already be installed and ready to build, refer to Jenkins – Windows Setup.

The Zebra Commerce build will perform the following tasks:

  • Monitor the Git repository for and changes (every 15 minutes)
  • Clone the Zebra Commerce Git Respository
  • Clean the Workspace to ensure a clean build
  • Run the Zebra Commerce Build script with the -NGIT flag (since Git is handled by the Jenkins Script)
  • Install the CoreFull version of ZebraCommerce to the local server
  • Create the Zebra Commerce Database for the Build
  • Import the Engineering Data Set

This configuration will create a full installation of the build that can then be used by the development team for testing.

Getting Started

The first step to creating a new build configuration is to create the project.  If this is the first project, simply select “create new jobs” to create the first project.  Otherwise, select “New Item”.

Next you will enter the Project Name and type of a project.  In this case it will be a “FreeStyle project” which is the standard to start from.


A form is then displayed that allows you to configure all of the details of the project, starting with a description of the project. JenkinsZC_1a_ProjectNameAndDescription

Source Code Management

For this project, we are using Git for our SCM and will be monitoring the repository every 15 minutes for any changes.  If there is a change, we will automatically begin a new build.

In the Source Code Management section of the Project Configuration form, select Git for the type of SCM.  If Git is not an available option, the Git Plugin has not been installed, you will need to go back to the plug-in manager and add it.

When adding git you need to add the repository URL and the Credentials.


By default Jenkins runs as the Local System Account so you can add the private key there, but I think a cleaner solution is to add the key directly through Jenkins.

JenkinsZC_1b_AddGitCredentialsNext we set up a few additional behaviors:

  • Set clone timeout to 60 minutes.  We do this because Zebra Commerce is a very large project and will time out at the 10 minute default.
  • Clean before checkout, so we always have a clean repository and don’t accidentally distribute objects from another build (we actually do this again later due to a bug in git).
  • Create a  new tag in the repository for each build.


Unfortunately the version of git that I am using has a problem with properly cleaning the repository, it does fails to delete a directory which has files that also need to be deleted, so we need to do an extra git clean.  To do, use the pre-scm-buildstep plugin to add an additional build step under the build section, “Add build step” and select “Execute Windows batch command”.  Add the command “git clean -fdx”.


By default, the project workspace is located in the Program Files, this is a bit hidden and also causes problems with long file names.  To move it change the directory in the Advanced Project Options.

JenkinsZC_1i_MoveBuildRepositoryWe then set the build triggers, in this case it will poll Git every 15 seconds to look for changes to the repository and will invoke a build if one occurs.

The SCM configuration is complete, so now is a good time to run a test build and ensure that it is working thus far.  Select Build Now and the build will begin.JenkinsZC_1g_TestBuildSCMOnly

You can also view the console output of the build while it is progressing but either the menu for the striped building indicator or selecting console output on the menu for the build on the status page.JenkinsZC_1h_TestBuildSCMOnlyRunning

Run the Build

Now we setup the actual steps for the build.  In the case of ZebraCommerce this will be running a Perl script in the build directory.  This is done with the an “Execute Windows batch command” under the Build section.

One thing to be careful of is the path when running as Local System User, you may want to set it here as well, e.g. “set Path=%PATH%;c:\windows\system32;C:\Windows\Microsoft.NET\Framework\v3.5”


Install the Build

Once the build is successful, we now automatically install the software in to a test environment.  This consists of:

  • Installing the Full version of the application
  • Restart the Data Import Services
  • Create the Database
  • Import the Test Data

This is accomplished by creating another “Execute Windows batch command” under the build section with all of the tasks.


Archiving Artifacts

Finally, once the build is successfully completed and the application is installed, we need to archive an artifacts that we want to maintain long-term.  The way Jenkins works is that there is a work space that is used to create each build and there is also a separate area for those artifacts to keep longer term.  These artifacts are available for download from the Jenkins web interface.

In this case we will keep the installation files for the application which Zebra Commerce places in the bin directory, during the build.  This is created in the “Post-build Actions” section with the “Archive the artifacts option’.  In this case the bin directory does not yet exist, so we receive a warning, but once the build is completed it will work.