Invalid Project Description, project path overlaps the location of another project with the same name When Importing Existing Android Project in Eclipse

I’ve got a new install of Eclipse and am setting up to do some Android development.

After getting the Develeper Tools and NDK Plugins installed and linking to the ADT-bundle that I downloaded, I was getting an error when attempting to import the existing project by going to File > Import > Android > Existing Android Code Into Workspace.

The error was:

Invalid project description /some/path/to/project/dir_name overlaps the location of another project: dir_name

After a few searches and a couple of tries, using the File > Import > General > Existing Projects into Workspace seemed to work just fine.

Restarting XServer in Fedora 20

I was having problems logging in this morning to my laptop.  When I entered my password, it just hung.   I pressed Ctrl-f2 to switch to an alternate tty, logged in as root and checked for errors in /var/log/messages.

Not seeing anything, I figured, I’d try and restart the Xserver.  Still not being completely familiar with the sysctl paradigm it wasn’t obvious how to restart it.

So, as root, I simply switched the runlevel to 3, and then back to 5 via the following commands, restarting the Xserver and was then able to login.

# telinit 3

…. wait for a bit ….

# telinit 5

Login, get to work.

Clone and Backup a Bootable USB Drive

We recently got a new ASUS laptop for the boys to use (I’ll use it too, it’s pretty sweet) which came with Windows 8.

It did not come with the install CD or license key, but included a recovery partition and the key in the BIOS.  Now that we’ve had it for a few weeks and verified that all of the hardware works, we are going to put Ubuntu on it, but I wanted to make sure that I would still be able to use the Windows 8 license on it if I wanted.

So, using the Win8 recovery program, I createad a bootable recovery disk onto a USB stick and I wanted to back it up, as well as be able to make a clone of it if need be.

Following are the dd commands to make that happen:

First, do a tail of /var/log/messages before you plug in the usb drive.  You should see it be recognized by the machine as sd[something].  Or, you can do an fdisk -l and should see the usb stick (as well as the other drives on your machine)

Be warned, make sure that you have the devices correct before you run these commands or you may destroy data on your machine.

Assuming that the usb stick is sdg, clone the disk to a file on another computer

dd if=/dev/sdg of=./windows_8_rcvry_usb_asus.dd conv=notrunc

Copy the file to another USB stick (assuming that /dev/sdg is the USB drive because all data on /dev/sdg will be destroyed during this operation):

dd if=./windows_8_rcvry_usb_asus.dd of=/dev/sdg conv=notrunc

Just make sure that the usb drive to which you are copying is the same size or larger than the original one that you copied from.

Creating a Beep from a Command Line or Shell Script

If you have a long-running command on shell-script that you want to generate a beep upon completion on your PC running Linux do the following:

Make sure that the pcspkr module is loaded:

# modprobe pcspkr

Then create a wrapper shell script that looks something like this:

#!/bin/bash

# Some long running command here . . .

echo -e '\a' > /dev/console

Eclipse Crashing with SIGSEGV, Problematic Frame libgdk and/or libsoup Problem Solved

I’m setting up a new workstation under Fedora Core 20 and getting my dev environment set up.

I had copied over my /opt dir from my old machine which included an older version of Eclipse (3.8.2) that I had been using.  That version wasn’t behaving very well and I decided to go with the latest and greatest stable version (Kepler, 4.3.1).

Unfortunately, Kepler was dumping core with the following error:

 A fatal error has been detected by the Java Runtime Environment:

  SIGSEGV (0xb) at pc=0x00000030f703d09a, pid=2450, tid=139984564643584

 JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)
 Java VM: Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode linux-amd64 compressed oops)
 Problematic frame:
 C  [libgdk-x11-2.0.so.0+0x3d09a]  g_param_spec_object+0x3d09a

 Core dump written. Default location: /home/rchapin/core or core.2450

I realized that I had installed Acrobat Reader, and since I’m on a 64 bit architecture that included all of the i686 rpms and compatibility libs.  I thought that that for some reason there might be some confusion between which version of libgdk that was being used.  That wasn’t it.  I tried a different JDK (Oracle vs OpenJDK), nope, that wasn’t it either.

Eventually, I tried deleting (actually moving aside) the .eclipse/ dir in my home dir and deleting all of the .classpath, .settings, and .project files and dirs in my workspace and then re-installing my Eclipse plugins for Kepler.

Worked like a charm.

What I think was happening was that some of the plugins for different versions of Eclipse were being pulled in at runtime and causing the Kepler binary to crash.

Excellent Example and Explanation on How to Inject Properties from an External Properties File from Outside of a WAR in a Spring Application

I am doing some refactoring on a Spring MVC application, pulling out configuration data and login crentials from the spring.xml file.

What I want to do is to consolodate sensitive data into external .properties files that can be read, at runtime by the app and not require recompiling the war to make changes.

Thanks to Ben Northrop and Summa Technologies for such a clear, concise and well written article.

The long and the short of it (copied from the aforementioned article) is to add the following to your spring.xml

<bean id=”propertyPlaceholderConfigurer”  
class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer”> 
  <property name=”locations”> 
    <list> 
      <value>classpath:database.properties</value> 
    </list> 
  </property> 
</bean> 


<bean id=”dataSource” class=”com.mchange.v2.c3p0.ComboPooledDataSource”> 
  <property name=”user” value=”${db.user}”/> 
  <property name=”password” value=”${db.password}”/> 
  … 
</bean>

Disabling Window Snapping for Fedora Core 20 Under Xfce

For me, window snapping is incredibly annoying.

For FC 20 with the Xfce spin, there a couple of knobs to turn before it can be turned off completely:

Applications Menu/Settings/Window Manager:

Go to the Advanced tab and uncheck ‘Snap windows to screen border’ and ‘Snap windows to other windows’

Applications Menu/Settings/Window Manager Tweaks:

Go to Accessibility tabUncheck the ‘Use edge resistance instead of window snapping’

Executing Dynamically Generated SQL Queries in a Shell Script and Saving the Output to a Variable

If you would like to, in a shell script, dynamically generate SQL queries for MySQL and save the output of those queries to a variable that you can then use in the script, here is an example:

#!/bin/bash

for i in `cat tables_list.txt`
do

   # Build the query
   QUERY="SELECT count(*) FROM ${i}"

   # Run the query from the command-line and save the
   # output into the $ROW_COUNT variable
   ROW_COUNT=$(echo $QUERY | mysql -u${USER_NAME} -p${PASSWORD} -h ${HOST} -P ${PORT} --skip-column-names ${DBASE})

   # Do something with the var...
   echo -n -e "$ROW_COUNT\t" >> $OUT_FILE
   echo "$i" >> $OUT_FILE

done;

Install Android Application Directly Without it Being in the Market

When developing apps you will not only want to test them against the Eclipse AVDs but also install them on an actual device.

To do so, set up an HTTP server (here is a link to another article on how to set up a quick and dirty HTTP server) and put you .apk file somewhere where you can get to it from your local network.

Make sure that you check the ‘Unknown sources’ setting that will enable you to install applications that are of non-Market origin. 

Then just open a browser on your Android device and download the .apk file.  Once done, when you attempt to open the .apk file the device will ask you if you want to install it.