adding library dependencies in android studio beta 0.8.9

In creating a new Android 5/Lollipop app that uses the latest Material Design, I created a new project and selected Android 5 (API 21) (NOT API 20+: Android L (Preview)!). In the process of bringing up the application, Android Studio threw exceptions that it couldn’t find Java class, among others. To solve this problem I had to add a support library (also known as a library dependency) to the project. This is accomplished via File > Project Structure (Ctrl + Alt + Shift + S) to bring up the Project Structure window.

To add a library dependency, select the Dependencies tab at the top right, click on the plus symbol on the far upper right (see big red arrow above) and then click “1 Library dependency.”

This brings up the “Choose Library Dependency” dialog. I’ve stretched it out to show all that are available to me. You selection will be dependent on the all the APIs you’ve chosen to support. I’ve highlighted the v4 support library. Once you’ve selected the dependency library you need click “OK” all the way back. Once that’s done the project will resync itself, and if you’ve found all the dependencies that project says it needs, Gradle will complete successfully.

Editorial Comment

I realize this is beta code. But this was a new project and all dependencies should have been automatically settled during the creation process. The way Android Studio is behaving right now it’s as if it were still late stage alpha code.

This is also one of the worst UI examples I’ve ever come across, bordering on disastrous. None of this is intuitive, all the way from digging out the main dialog. I know that Google didn’t write the IDE, but they selected it, and they now share responsibility for how bad it is. And this is very bad indeed.

Posted in Android, Development, Google, Software | Leave a comment

tweaking raspbian on the raspberry pi B+


Raspberry Pi B+

I spent some time today working with the latest Raspbian, tweaking it to work with my Apple keyboard.

Just as with Arch Linux (see “tweaking arch on the pi” from February) I had to fix the function keys, i.e. make them functional. Before that could happen, I had to fix the key mappings on the Apple keyboard by running ‘sudo dpkg-reconfigure keyboard-configuration’ and selecting English(US) mappings. For whatever reason they’re set for English(UK). Then I had to create the file /etc/modprobe.d/hid_apple.conf and add the line ‘options hid_apple fnmode=2′. Reboot, and I had a full US English Apple keyboard with working function keys.

One feature I fully appreciated in Raspian is its ability to set the time from the network, once the networking was properly configured. I got the wireless network running through the Lxde desktop and the graphical network utility. Once I had the wireless network connection set up, all further reboots set the time on the board. The board doesn’t have a battery-backed clock. With Arch Linux it always sets to 1969 unless I run a simple script to execute ‘ntpd -q -g’ at startup, which I was forced to add myself.


Performance was a bit of a mixed bag. If I logged into the command line, Raspian seemed to execute faster and smoother than Arch Linux. But run the graphical desktop, first with LXDE and then XFCE4, and things got slower, many times annoyingly so. I did certainly appreciate the update to the Epiphany browser; it worked as well as advertised, but it also slowed considerably when it hit a site with a lot of complex features, such as this WordPress blog. I had hoped to write this update from the Raspian desktop, but I turned back to my workhorse Ubuntu system on the now-five-year-old Samsung R580 notebook to write this.

General Conclusions

Raspbian’s a good distribution for the Raspberry Pi B+, but for my tastes I think I’ll stick with Arch Linux for Arm. I had thought to try and unify all my Linux environments as much as possible around Ubuntu/Debian, but that won’t happen any time soon. My greatest concern outside of performance is drive footprint. Raspbian came out of the box consuming more drive space than Arch Linux, and I’ve been tinkering with Arch Linux since late January. When I installed Xfce, Raspbian’s overall footprint had grown to 2.7 GB, a good .5GB greater than Arch Linux, and that’s even after uninstalling Lxde from Raspbian.

Posted in Arch Linux, Linux, Raspberry Pi, Raspbian | Leave a comment

raspberry pi b+ – arch linux update and future plans

Raspberry Pi B+

Back in August I picked up two new little computers, the Raspberry Pi B+ and a Beaglebone Black Rev C. I moved my rolling Arch Linux for Arm from my older Raspberry Pi B to the B+. The Beaglebone came with Debian pre-installed.

Beaglebone Black Rev C

Since receiving both boards I’ve had little time to work with them, either individually or as part of a larger project. As usual I had the best of intentions, but life interfered, and with the exception of just powering on the boards a bit and seeing if they worked, everything has been sitting in my big storage box for such items.

What makes this even more annoying for me is I also ordered three P8X32A-D40 Propeller chips, and even had one of them working in the Propeller developer’s board. The long-term goal has always been to integrate the RPi with the Propeller using an I2C channel. I had hoped to have everything working together before now. Both boards were ordered from Adafruit.

Software Update

I’ve gone and updated Arch Linux Arm for the Raspberry Pi. It runs fine on both the prior B and the current B+. I’ve created a compressed image and moved it up to my Google Drive location here. The compressed image is 1.6 GB compressed, and fits on an 8GB or larger SDHC card. I’ve switched from zip to compressed tar. The readme is here on Google Drive.

This may be the last Arch Linux release. Because the Beaglebone Black is pre-loaded with Debian, and because there is now a more current Raspbian (Debian-based) release for the Raspberry Pi, I’m looking at moving all my Raspberry Pi development to Raspbian in order to make the development environments on both boards as close as possible. This also fits in with my primary development system which runs Ubuntu 14.04.


I installed Raspbian and booted into the system. Initial configuration was well thought out. On first boot you’re presented with a simple character-based menu. The first entry is to resize the active partition to use the entire micro SDHC card. I am using 16GB cards these days, and it was a pleasure to have the partition simply and cleanly repartitioned to use all 16GB. I had to use a separate Ubuntu utility to resize the Arch Linux partition to 8GB (that’s what I had at the time).

Right now my Raspbian installation boots into a simple command line environment. If I want the desktop I run startx, which boots the desktop into LXDE. I’m no fan of LXDE, and it looks like I’m still not. But I have to admit that it runs much faster and smoother than the first time I tried Raspbian. What’s most impressive about the latest Raspbian desktop is the latest Epiphany web browser. It isn’t perfect, but it’s still amazingly good on such minute hardware as the RPi B+. I’m suitably impressed with this iteration.

Posted in Arch Linux, ARM, Raspberry Pi | Leave a comment

rolling with a different distro: centos 7

Because they’re so cheap I bought another 1TB Western Digital Blue drive from a local big box electronics store, swapped it into my R580 notebook, and installed a few other Linux distributions on the blank drive, eventually stopping at CentOS (Community ENTerprise Operating System) 7. CentOS 7 is Redhat Enterprise Linux (RHEL) 7 with all the Redhat branding and logos stripped out as well as the RHEL licensing structure. What’s left is an enterprise class version of Linux without any of the paid for RHEL hand holding.

There are a number of key differences between CentOS 7 and Ubuntu 14.04. One that’s important to me is support for RPM (Redhat Package Management) install files as opposed to Ubuntu’s DEB (DEBian) files, and all the tools built around those formats. Truth be told I prefer rpm and yum to deb and apt-get, although when you compare them dispassionately there’s really very little difference between them. Those folks that claim there is are the “fan boys (and girls)” of their distribution. I’ll be honest enough to say that long years of experience make me more comfortable using rpm, but that doesn’t make it overwhelmingly better.

One language I use and develop with is Java, choosing to use the official Oracle releases, which are pushed out either as ZIP, TGZ, or RPM files. No DEB files. It’s far easier to install via RPM on RPM supporting operating systems, such as RHEL/CentOS, Fedora, and openSUSE. If I want to use Oracle Java on Ubuntu then I have to go through some additional gyrations unpacking the TGZ file, as I’ve documented in previous Ubuntu posts.

In order to use Oracle Java I have to completely uninstall the Open Java/Iced Tea variants that just about every distribution wants to install. I dislike all those variants because they’re incomplete, don’t operate as correctly as the official Oracle release, and are always a few releases behind. And every time I uninstall Open Java I’m also forced to uninstall Libre Office due to insane dependencies of Libre Office on Open Java built-in to the distro.

CentOS 7 was no different, but it was straight forward and fast, unlike openSUSE 13.1. After removing Open Java and Libre Office, I installed Oracle Java 8 update 20, then downloaded the latest Libre Office (version Sometimes you need to bypass the repos due to version rot not only for the latest Java, but the latest Libre Office as well. The CentOS versions of Libre Office are at as of the date of this post. The primary driver is that Microsoft Office compatibility in Libre Office 4.3 is much better than in version 4.1.

I just mentioned openSUSE 13.1. That’s because I tried out OpenSUSE 13.1 KDE before settling on CentOS 7. While openSUSE installed fairly well, it had enough oddball quirks to it that I eventually installed CentOS 7 over it. Biggest problem with openSUSE is KDE itself; it’s changed to the point where I don’t like it at all any more. That’s a shock from my early days of 2007, when I fell in love with KDE 3. OpenSUSE is now completely off my radar.

One thing I will say about the latest Linux distributions, and that’s how they all effortlessly handle hardware. With all distributions both screen and network were easily detected and used. The wireless chip set on the R580 was the most surprising success; in all cases the chip set was detected and enabled. All I had to do was pick my home network and give it the password. After that it just ran.

Another big surprise is how all the distributions have current browsers, and how the current browsers handle multimedia. You’re looking at Firefox 31.1 above running a YouTube cat video using HTML 5 (no flash here!), complete with audio. When something as conservatively hidebound as CentOS 7 can run YouTube cat videos without flash, without turning to running arcane post-install command-line tools or installing additional “non-free” software from “non-free” repos, then you know the apocalypse has truly arrived.

Once installed it ran smoothly and without any incidents. I installed Oracle Java as well as the latest Libre Office. I also installed a few tools, such as gcc and g++, and then forked and built the latest node.js off of Github. It all built cleanly, and ran as well as it has on every other OS I’ve dropped it on. I tried some other hackery and it all worked as expected. From a software development perspective, CentOS 7 is like Mary Poppins, practically perfect in every way.

As good as CentOS 7 might be operationally and internally, I do have a number of complaints about CentOS 7. The first is how it looks.

CentOS 7’s desktop, which is their version of Gnome 3, looks like a poorly implemented copy of Mac OS X 10.5 (see above). If I’d wanted that look I’d have bought myself a Mac. Back in 2008 or so. The shadowing looks better on Mac OS X, while CentOS 7’s desktop decorations seem to take up too much space, especially between widgets.

Other annoyances include the desire of the Gnome developers to remove features, such as Nautilus’ ability to show previews (it once did), or the Gnome terminal’s loss of transparency in Gnome 3 (in Gnome 2 it was really very nice), or the inability to select gedit’s color theme (I always go in and select cobalt). Thankfully, they’re features that are still available in the same tools under Ubuntu 14.04. These are the kind of operational issues that tend make people like me cranky.

It’s been interesting playing with CentOS 7 this weekend, and I’ve certainly learned a lot. There’s certainly much to appreciate in CentOS 7. But as much as CentOS 7 has improved over all other versions of CentOS, I think I’ll stick with Ubuntu for the time being. In the mean time the CentOS 7 drive goes into storage until such time as I might have need of it.

Posted in CentOS, Linux, Ubuntu | Leave a comment

building web applications with mongo db: an update

It’s been a while since I did anything with MongoDB, a NoSQL (Not Only SQL) open source database. My MongoDB rad skills[1] had gotten a little rusty as a consequence. So I moseyed on over to the MongoDB download site, grabbed a zipped up Windows x86-64 copy, plopped it down on my machine, and then started to follow the directions to “Building Web Applications with MongoDB: An Introduction.”

It’s a great little presentation, but it has a few little quirks that this posting is meant to smooth over. They are:

  1. His presentation is on Mac OS X. This update is for Windows 8.1 Update 1 64-bit.
  2. This update contains the full source code to the three web application files, with a few minor corrections.
  3. This update contains a MongoDB console correction.

This update is preparation to get everything set up on Windows 8.1 before running the presentation. When you run the presentation it will go a lot smoother for you. And you should run the presentation to get the full benefits of learning about MongoDB. But first the software we’ll need to install:

Software Version
Python 2.7.8
pymongo 2.7.2
bottle 0.12.7
MongoDB 2.6.4

Please note that these are the versions as of the time this post was published. If you come across this post at some point in the future, they may be different (i.e. higher).

First let’s install Python and the infrastructure tools for the MongoDB Python driver and web infrastructure you’ll need to run the presentation.

  1. Pick up the Python software from ActiveState’s ActivePython download page. Make sure to select a version 2.7 Python. Pick the 64-bit MSI installer, run the installer, and take the defaults. It will put all the binaries and tools into C:\Python27.
  2. After the Python installation open a command shell and cd into C:\Python27\Scripts. There you’ll find easy_install.exe and pip.exe. You can use either tool to install pymongo and bottle, but it’s easier to use easy_install. For pymongo type “easy_install pymongo” followed by “easy_install bottle”.

Next download the MongoDB database software from the MongoDB download page. Select the 64-bit zip file. What follows is how I have my sandbox set up for this. You can change it to suit your environment if you want.

  1. Create a local sandbox area. Mine is C:\Java (an historical artifact).
  2. Unzip the MongoDB zip file into C:\Java. My unzipped MongoDB application is located in C:\Java\mongodb-win32-x86_64-2008plus-2.6.4
  3. Create a directory structure for the MongoDB data store. Mine is C:\Java\data\db
  4. In the C:\Java\mongodb-win32-x86_64-2008plus-2.6.4\bin folder create a batch file called runmongo.bat
  5. In that batch file put the single line ‘mongod –dbpath C:/Java/data/db’. Now you can double click it in the file explorer and start up MongoDB pointing to where it should place all its data files.

Finally create a sub work folder to hold the application file. Mine is C:\Java\MongoDB. Place the following three files into that location. I use the MongoDB subfolder just to keep things straight, but you could call it Fred and it would still work. What follows are the three files to copy:

import bottle
import pymongo
import guestbookDAO

#This is the default route, our index page. Here we need to read the documents from MongoDB.
def guestbook_index():
    mynames_list = guestbook.find_names()
    return bottle.template('index', dict(mynames = mynames_list))

#We will post new entries to this route so we can insert them into MongoDB
@bottle.route('/newguest', method='POST')
def insert_newguest():
    name = bottle.request.forms.get("name")
    email = bottle.request.forms.get("email")
    guestbook.insert_name(name, email)

#This is to set up the connection.

#First, set up a connection string. My server is running on this computer, so localhost is OK.
connection_string = "mongodb://localhost"
#Next, let PyMongo know about the MongoDB connection we want to use. PyMongo will manage the connection pool.
connection = pymongo.MongoClient(connection_string)
#Now we want to set a context to the names database we created using the Mongo interactive shell.
database = connection.names
#Finally let our data access object class we built, which acts as our data layer, know about this.
guestbook = guestbookDAO.GuestbookDAO(database)

bottle.debug(True)'localhost', port=8082)



import string

class GuestbookDAO(object):

#Initialize our DAO class with the database and set the MongoDB collection we want to use.
    def __init__(self, database):
        self.db = database
        self.mynames = database.mynames

    def find_names(self):
        l = []
        for each_name in self.mynames.find():
            l.append({'name':each_name['name'], 'email':each_name['email']})

        return l

    def insert_name(self, newname, newemail):
        newdoc = {'name':newname, 'email':newemail}



<!DOCTYPE html>
        <title>Welcome to MongoDB!</title>
        <style type="text/css">
            body { font-family: sans-serif; color: #4f494f; }
            form input { border-radius: 7.5px; }
            h5 { display: inline; }
            .label { text-align: right; }
            .guestbook { float: left; padding-top: 10px; }
            .name { width: 100%; float: left; padding: 3px; }
            .wrapper { padding-left: 25px; padding-top: 20px; }

        <div class="wrapper">
            <h1>Welcome To MongoDB</h1>
            <div class="guestbook_input">
                <form method="post" class="form" action="/newguest">
                    Name: <input type="text" name="name"/>
                    Email: <input type="text" name="email"/>
                    <input type="submit" value="Add Guest"/>
            <div class="guestbook">
                %for name in mynames:
                <div class="name">
                <h5>Name:</h5> {{name['name']}},
                <h5>Email:</h5> {{name['email']}}

File: index.html


Copy these three files into C:\Java\MongoDB.

Go to the MongoDB presentation and follow along. When it comes time to start MongoDB double click the startmongo.bat file in the file explorer. When it comes time to start the MongoDB shell, double click mongo.exe. When it comes time to run the web application in C:\Java\MongoDB (comprised of those three files you should have copied there) open a command prompt, cd to C:\Java\MongoDB, and type ‘python’ and hit return. Then follow the rest of the demo.

Note that when the demo talks about deleting records in your web application’s database, you should type ‘db.mynames.remove({})’ instead of ‘db.mynames.remove()’. MongoDB has advanced enough from the version used in the demo to cause some minor annoyance if you follow the speaker’s directions exactly.

[1] I guess I’m an old fart; I refuse to spell the plural of skills with a ‘z’.

Posted in Software, Web, MongoDB | 1 Comment