Tuesday, September 29, 2015

Testing with Android Studio

Tried to write this in the order one would discover how to configure and test in Android Studio. Test support has come in many forms with different purposes in AS(Android Studio). There are/were plugins and various 3rd pty libs. AS now supplies its own test platform. None of which is configured to fly right out of the box.


Get the Android Support Library from SDK manager. Recently the manager has been moved to the setting interface. You can still get to the old sdk interface.
Testing Support
Verify you have the libs in your sdk folder.

Create a new project to test with.

Create a new blank activity app.
  • compile app
  • open the default MainActivity class
Gradle plugin testInstrumentationRunner needs overriding.
  • Manually change the build.gradle file. If you search the gradle site for testInstrumentationRunner you will see the default is “android.test.InstrumentationTestRunner”.
  • Wasn’t able to find UI way to change this value.
  • This will come in handy as it supplies a value for the debug/run config interface.
defaultConfig {
        testInstrumentationRunner ""
Open create test interface
  • right click on the MainActivity class name -> Go To -> Test
  • CTRL + SHIFT + T
Configure the test interface
  • select JUnit4 and Fix (what does fix do?)
  • select one or more methods to test and before after checks
  • should create import statments and test methods in test class
choose the destination test directory interface
  • the one that contains “src” in the path
  • this can be a larger list if you have other modules in your project
Should have a new file MainActivityTest in the test directory.
  • The build.gradel file still does not have reference to the important libs we are going to use “*”
Apply the first annotation that requires reference
  • Add @RunWith(AndroidJUnit4.class) to test class
  • Alt + Enter @RunWith to create import
  • AndroidJUnit4 class reference not found. Dependencies missing.
Add* dependencies to the project
  • modifying build.gradle is can be done via the project structure interface. (or manually)
  • select your app right click and select "open module setting (F4)
  • select the module app and choose the dependicies tab
  • find the + - buttons + add the “library dependency”
  • paste in the full lib name in the “choose library dependency” interface. It will not work with a partial match.
  • change the “scope” to Test compile.
  • OK, clean, compile
  • you should see the new references in the (app)build.gradle file.
Here are the latest libs for test support. They will change.
Add the import reference AndroidJUnit4.class
  • dependency should now exist for AndroidJUnit4.class
  • Alt + Enter AndroidJUnit4 to create import
Setup one test to Pass
  • we will use assertThat from
  • add this test method
public void DonkeyTest() throws Exception {
    assertThat("", is(""));
  • Alt + Enter “assertThat” to create import
  • Alt + Enter “is” to create import
Try running the test
  • Right click on test class file. Should see Create, debug, run
  • Select Create to generate a run configuration
  • The “Specific Instrumentation runner(optional):” is not optional. Should be already set to “”
  • if not select … and choose “”
  • Apply, Ok
  • Right click again and select run/debug
  • If you goto “Edit Configurations” you can delete what was made in this step.
Locate the results
  • Run dialog should show the Result / Command / Test Method


Getting an idea of where all the moving parts are is a good first step. Primary suspects is the presense of the testing libraries and the correct configuration of the build.gradle.
There are a lot of new api introduced which can be overwhelming. Hard to tell which is the current official storyline.
Google is making attempts at gathering this config stuff in one spot with Android Testing Blueprint


Friday, September 11, 2015


Arriving at the conclusion that you need virtualenv you quickly enter into how_where_what land.  Your why is because you want multiple versions of python and to pip packages to your hearts content.

This site virtualenv sums it up pretty well but is kind of light on the details.  After reading it you start wandering around for more answers.   Each environment kind of has its own tricks and traps.

I wanted to know how-does-virtualenv-work without reverse-engineering-ian-bicking.  Final answer is: this shell these paths please. 

Before getting into virtualenv you would want to know more about "pip" (package manager).   Pip is one of a set of tools that put the python packages into the python user space.  

So don't forget that the virtualenv command just populates a directory with all the folders and symlinks to the python binaries you want.  

activate and deactivate command exist in reference to the environment that was setup by virtualenv.  They engage and disengage those paths that now exist as directories in your directory.


sudo apt-get install python-dev python-pip python-virtualenv


Really good rundown on setting up. run-multiple-python-versions-on-your.  Pay attention to the how he manages his environments and the use of ~/.bash_alias



Friday, May 1, 2015

Ubuntu 14 Android Studio setup notes

Setting up Android Studio on Ubuntu requires many extra packages. Here are some notes on setting up the latest versions. Special note that you want a CPU that supports the android emulator. I used an AMD with graphics support.

#requires java 7

sudo apt-get install default-jdk

#getting the packages

mkdir Android

cd Android


tar -xvzf android-sdk_r24.0.2-linux.tgz



#add $PATH to end of  ~/.bashrc file

export PATH=$PATH:~/Android/android-studio/bin

#required packages 

sudo dpkg --add-architecture i386
sudo apt-get update

sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386

#setup the KVM (virtual machine)

#verify kvm is funtional before running android studio setup.



sudo apt-get install qemu-kvm libvirt-bin bridge-utils
sudo apt-get install virt-manager
sudo apt-get install qemu-system

#logout or reboot

#start studio by opening termainal and run

#update the sdk and add emulators

Friday, July 11, 2014

Trommel rock separator

Trommel are very handy when you have very rocky soil.  A good instructables here Trommel.

Monday, January 27, 2014

DIY PVC-IKEA Treadmill Desk - Again

Wanted to make another desk and needed to simplify the construction.  This desk uses all 1.5 inch PVC tube and fittings and only requires cutting the tubes.

Went back to Ikea with some of the PVC parts and re-though the connections.  The metal table legs fit perfectly into the 1.5 inch PVC pipe. 

To tighten the connection between the table leg and the PVC make a vertical cut at the end of the pipe and push a coupling down.  The coupling will apply pressure and jamb the PVC against the metal leg.  

The angle brace is 1 inch PVC with a elbow connection.  Drilled a hole in the elbow and used a drywall screw to fasten the main brace bar.  Drywall screws where also used on the other two locations. 


Table top: LINNMON  $16
Legs:  LINNMON/ ADILS   4 @ $3.5 per leg


2@ 10 foot 1.5 inch PVC40
4@ 1.5 inch coupling
4@ 1.5 inch elbow
2@ 1.5 inch tee

Odds and ends:

3@ 2 inch drywall screws.

PVC angle brace could be 3/4 inch tube with a single elbow connection.


Miter box saw is handy to create nice clean cuts.
A cordless drill / screwdriver is handy.
Tape measure.
Level to adjust table finished height.

Wednesday, August 28, 2013

DIY PVC-IKEA Treadmill Desk

DIY PVC-IKEA Treadmill Desk

check out the latest version

Built this treadmill desk for about a hundred bucks.  Gets me up and walking while I work which has been great.

Used 2 and 1.5 in PVC.  The legs extend for height adjustment.  Ikea sells the desk part for 15 bucks and the leg attachments I found in the 1/2 off bin.  Didn't end up needing Ts for the feet and could have just used a 90 degree elbow.  Routing out the 1.5 to 2 in reducer for each leg was difficult and would recommend a sanding brush drill bit to do the job.

A couple months have passed....

Recently I added some  Flo Monitor Supports.  They are lightweight and easy to attach.

Sunday, March 18, 2012


The kombucha is very easy to make.  There are many good instructions on the interweb.

You don't need to buy a mother to start out just a good bottle of kombucha.  These instruction are detail just that.


Here is what you need.

2 gallon heritage hill jar.  Like this one from target.  14 bucks.
2 gallon heritage hill jar

Get a bottle of your favorite kombucha from the store.  Get one that is not flavored and in a brown bottle.

Get a black tea like Lipton or PG Tips.  No flavored teas, green etc.  Just plain black tea.  About 6 regular tea bags per 2 gal batch.  Stronger is not better. 

White vinegar.  As this is a starter batch and the Ph won't be high enough from just the bottle of kombucha.

A thin cloth like a dinner napkin or hanky with something to tie it to the lid of the jar.  Use a cord or link together several rubber bands.

A kettle to boil 2 gallons of water in.  Stainless steel is preferable.

2 cups of white granulated sugar.  1 cup per gallon.


Bring the two gallons of water to a boil.  Add your tea for 10 min.  Remove tea.  Add sugar and dissolve.  Then put lid on kettle and allow to cool to room temp. 

Pour the sweet tea into glass jar.  Add your entire bottle of kombucha.  1/4 cup of vinegar.  Put cloth over jar opening and bind it so it doesn't slip off or sag into jar.

Wait two weeks.  Keep the jar in a dark warm place.  Don't poke or disturb.  No real action is ever to be seen except for the slow formation of the mother.

Basically you have to keep the finished kombucha in the fridge or it will keep growing.  I decant into glass beer bottles and cap them.  Placing a small piece of candy ginger in the bottle.  Let the bottles stay at room temp for a few days to get some carbonation up before refrigerating. 

Leave some of the kombucha in the jar with the mother.  You will need one cup of the original batch and the mother to make the next batch.  You won't need to use the white vinegar again as the starter has enough acid in it.