AVD Manager in Eclipse on Ubuntu won’t start device due to double slash error

I have a weird error that happens to me every time I rebuild my machine; when I open Eclipse and attempt to start up AVD Manager, I get an error when I hit “start” for the Android 4.1 virtual device. That error contains this line: “android-sdk-linux//tools/” and has to do with not finding the adb tool. That’s rather obvious; there’s a double slash in the path that the AVD Manager is using to try to find the script.

The fix, oddly enough, is due to a lack of the ia32-libs package on a 64-bit Kubuntu build. Install it to include support for your 64-bit system.

sudo apt-get install ia32-libs

How to read from the Assets folder in an Eclipse Android application

Seeing errors like these?


java.io.FileNotFoundException
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:315)
at android.content.res.AssetManager.open(AssetManager.java:289)

The problem is that Eclipse isn’t finding your file, because you may not be using AssetManager to retrieve plain-text files from the assets folder. Here’s how to fix this:

  1. Note that there is no file extension on text. When I pasted ‘text.txt’ into the Assets folder to begin with, it had no extension. I tried and tried to get the app to recognize that Assets had a text.txt file in there, and finally tried it with no file extension as it appeared in the folder view.
  2. The try/catch AND the throws declaration are necessary to handle Eclipse’s fiddly compiler.
  3. Don’t cry. If you still can’t figure out how to get Eclipse
    and your app to read the file, clean the project (Project –> Clean), make sure that the Assets folder is NOT on the build path, restart Eclipse, ensure you have no other errors (ADB, DDMS, anything), and try again. If it still doesn’t work, comment here and I’ll both try to help and make updates to the code.


public void openFile () throws IOException {
System.out.println("Starting openFile now");
AssetManager am = context.getAssets();
try {
InputStream is = am.open("text");
BufferedReader in = new BufferedReader(new InputStreamReader(is));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}

Useful links (none of which contain the entire solution, but all of which had some piece):

http://stackoverflow.com/questions/6039862/location-of-apk-file
http://stackoverflow.com/questions/5086539/reading-file-from-assets-directory-throws-filenotfoundexception
http://developer.android.com/reference/android/content/res/AssetManager.html
http://developer.android.com/reference/java/io/InputStream.html
http://stackoverflow.com/questions/5771366/reading-a-simple-text-file
http://stackoverflow.com/questions/10267594/how-to-access-
assets-folder-in-my-android-app

http://stackoverflow.com/questions/9674815/trouble-with-reading-file-from-assets-folder-in-android

Which JSON library should I use in my Android and Java projects?

JSON.org is where you start; this is the prepackaged JSON found in Oracle and Open Java Development Kits. The home page is a useful resource to see all the different JSON libraries out there for all different languages.

GSON is most useful for converting Java objects into their JSON representation. The Google libs can also convert a JSON representation into a Java object; this can be a game-changer for dealing with inheritance.

FlexJSON has a serious strength in web development. Because you can specify deep or shallow copies of objects, you can speed up transmission of information from backend Java code to your front end and client-facing architecture.

Jackson is almost certainly
the fastest JSON parsing library out there; it’s an active project, and has speed and flexibility to recommend it. I have started using it by default. Most useful is the fact that you can switch between a tree model and object mapping at will. It has a JSONFactory method that is extremely useful when parsing and manipulating JSON representations that need to be read, processed, and rewritten to provide data to an Android app.

JSON-lib is mostly focused on translation. Need to translate objects and data back and forth between Java objects, beans, servlets, and DynaBeans? This is the lib to use. Notably, it’s a bit heavy, as you might expect from a translation-centric library, so it’s probably best used when you’re managing legacy code or are a one-woman-shop.

Vegan Tab with Viewsonic gTablet

I’ve obviously been busy for the last month, and the posts concerning the LadyCoders Kickstarter will appear on the ladycoders.com site. I’d really rather get back to the fun of reviewing a hardware/OS combo.

About three weeks ago, I got a used Viewsonic gTablet and flashed Vegan Tab on it. I’ve never had a tablet before, and I was thrilled to get to play with all the other pinchers and swipers. I like Vegan Tab, but there are a few issues that we need to discuss.

1. The most widely-used and recommended browser, Dolphin, has some serious problems. I use 2-step authentication on Gmail, as any moderately security-conscious person does, and Dolphin will not load my Gmail inbox. I use the Authenticator and my password (you do not use the third-party application passwords since this is theoretically a full browser, not an application), and the load hangs at about 97%.

2. Memory
on the Viewsonic and with Vegan Tab seems to be underallocated to the top processes. Checking the running processes yields only about 10% to the top process, and though I use an auto memory manager app, forcibly reassigning active memory to the top processes does not appear to positively affect my user experience. Comic Book Viewer keeps dying when loading Sandman pages, which is irritating.

3. Several applications that should work or have tablet equivalents do not. TweetDeck is a standalone application on my Android phone (a Motorola Droid 4), and does not install on my tablet. What is even more unfortunate is that TweetDeck will also not load in any browser on this tablet.

4. Swiping and pinching works well, though there is often serious lag in browsers due to that memory issue.

5. Wifi operates smoothly and rapidly except in the case of LANs. At DefCon, I had a problem connecting to a LAN to download some puzzles, and the IP address beginning with 10 hung the scanner. In addition,
Ethernet connections via cat-5 do not appear to be functional in Vegan Tab, though there’s apparently a hack for that.

More comments or notes? I’ll probably edit this post if I find any other peeves. The experience is as positive as I could get, considering that this is an older tablet running a nonstandard flavor of Android.

Dream gizmos

There’s a refrigerator that runs Linux now. That seems like a bit of overkill to me, but there are a few devices around the house that I think could use a bit of OSS ingenuity.

We have hibernation features for most laptops; is there a way to hibernate, say, a kitchen? Energy vampires like toasters (and I’m only going off of popular rumor, not fact here) are supposed to suck watts even when powered down. Wouldn’t it be handy to run a script that actually interfaces with your house’s power systems? I bet Bill Gates’ house does that already, so it’s time for the NIX crew to get it together 😉

My dream device: A kitchen touch screen computer like this one, but which can also be interfaced with remotely, and which can control the oven, the yogurt maker, the coffee
pot, and the dishwasher. With that, I’d be able to interface my OurGroceries list with the kitchen’s DB on food stores, cook something remotely that requires a long cooking period with changes in temperature over time (like a crown roast), preheat the oven as I’m getting home to throw a pizza in, and which can warn me if the freezer or refrigerator rise above a certain temperature (a sure sign that the cats have found a way to knock open a door).

How about you?

How to SSH into your home computer to access media files, documents, processes, or anything else you might need

I wanted access to my home machine so I could access any files I want. Dropbox is pretty awesome, but if you’ve forgotten to put something in your Dropbox folder, you’ll be in deep trouble.

(1) Run “sudo apt-get install openssh-server” at the command line.

(2) Run “sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original”. This copies your original configuration file for SSH so if you muck up the settings, you can always replace them.

(3) Run “sudo kate /etc/ssh/sshd_config” (or whatever text editor you use) and change the port number from 22 to another port so you won’t be targeted by so many bots.

(4) Ensure that your firewall isn’t blocking the port you chose. You may need to add SSH as a running service. You should probably also include ‘sshd’ as a startup application in your distro so that if you need to do a remote reboot, the service restarts and you can log back in.

(5) Forward the port
being used for SSH in your router. To do this, you need the internal IP address of your computer on your home network, as I presume you’re not dumb enough to directly connect your home machine to a modem. Ask me if you have problems figuring out how to forward the port.

(6) Get out your Android phone if you have one, since a connection over 3G will mean that you can test your SSH connection without ever leaving your comfy chair. Install ConnectBot through Android Market.

(7) Open ConnectBot (or any SSH client from any machine; Putty will work well) and type in your home machine username, your external IP address, and if you have changed the port, include that as well. Here’s the format: username@000.000.000.000:XXXXX Where 000.000.000.000 is your external IP address and XXXXX is the port number you chose to replace the default.

(8) If you have issues getting a connection, hit me in the comments; I had several oddities in router configuration making this work, even though it’s
quite simple in theory.

Simple tip to make Android easy to access…

…via your home wifi server.

(1) Install On Air from the Android Market.

(2) Ensure that your home wifi is accessible through your phone’s Settings menu.

(3) In On Air, set your preferences to “use the same 4-digit code”.

(4) Hit the big button to turn on the FTP server on your phone.

(5) In your chosen file manager (mine is Dolphin), FTP into the phone, using the 4-digit password generated by On Air. Save the password, and bookmark/save that FTP location to your Places view or some easy place to find it.

Bingo! Now, you only have to hit the big button on On Air and browse to that place in your file manager to remote-access your phone.