I bought my G1 phone today. Yes, my Android phone. Dude. Am I happy. It is soo much faster than the emulator. So much fun. Not much time to play with it yet.
When I got it home tonight, I got to the task of getting my application installed on it.
Obviously the way to go is to just publish the application to one of the many marketplaces.
But, my app isn't ready yet. I want to install it on my phone and play with it and to get feedback from friends.
Here are the steps to getting that app on your phone. Maybe I will clean this up later.
Use keytool. From the command line (you obviously need the JDK installed):
Now you have a key. We will be using a self-signed key. Don't worry. Android accepts that.
Now you need to sign your .apk file. Screw the command line. You're gonna be doing this a lot. Use ant. Ant has a core task called oddly enough signjar.
Here's a build file you can start with.
Run the build. Hopefully, the "build" succeeds. Check the last modfied date on your file. It should have updated. It if it did, your jar should be signed. I'm sure there's a more intelligent way of examining it.
Now you can install your app on your phone. How the heck do you do that? Well, you need a server. Just install Tomcat locally. Copy the file to a simple web app. Modify your web.xml file (or your web server) to treat the .apk file extension as "application/vnd.android.package-archive".
Now add a link to your file in a web page or JSP. Hopefully the PC/laptop you're running this little local app is on your local network. And, you've turned on wi-fi on your phone. Go to your browser on your phone. Access your pc/laptop: http://192.168.1.10/yourapp/yourfile.jsp or some such url). Click the apk file and the Chrome browser should download the file. Once the file finishes click on the file. It should try to install the application. If it fails, it will tell you so. Unfortunately, it doesn't tell you why it failed. If it succeeeds, it will tell you and allow you to launch it.
Good luck!
Showing posts with label java. Show all posts
Showing posts with label java. Show all posts
Wednesday, October 22, 2008
Tuesday, October 7, 2008
Classpath Doh!
I keep learning more and more about building complex systems and the importance of getting classpath correct.
The other day I did an SVN update on my project. All of the sudden, this one piece of code wouldn't compile. I think it's probably OK to show this 1 line of code.
Anyway, the bit that was barking at me was
I asked a colleague where this lives. In rt.jar, he says. Waa? OK. It's in the JDK. I looked around in rt.jar. Yep. It's there. Why the hell isn't it compiling then?
Hmm. Here's the answer.
Project | Properties | Java Build Path | Order and Export
There was a jar in our project (which wasn't being used any longer) called jsr173_1.0_api.jar. That jar contains a class in the javax.xml package called XMLConstants just like in RT.jar. Only this copy did not have
It was an easy fix for us. We were able to simply remove the unused jar from our project and the problem was gone. But, what if we couldn't remove it? Hmm. You can cheat, at least in the IDE. Though I'm sure that might have caused deployment issues. You can re-order the classpath by moving a class up or down in the list. Just click the jar in question and move it below the JDK entry. Voila, it compiles.
Be careful out there. It's a weird classpath world.
The other day I did an SVN update on my project. All of the sudden, this one piece of code wouldn't compile. I think it's probably OK to show this 1 line of code.
Anyway, the bit that was barking at me was
javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI
.I asked a colleague where this lives. In rt.jar, he says. Waa? OK. It's in the JDK. I looked around in rt.jar. Yep. It's there. Why the hell isn't it compiling then?
Hmm. Here's the answer.
Project | Properties | Java Build Path | Order and Export
There was a jar in our project (which wasn't being used any longer) called jsr173_1.0_api.jar. That jar contains a class in the javax.xml package called XMLConstants just like in RT.jar. Only this copy did not have
javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI
. But, why does that affect whether it compiles or not? The jar without the class was listed higher in the classpath order. We didn't notice the problem before the JDK was previoulsy higher in the classpath order. Someone had re-ordered it on the last commit. Ugh. But, I'm glad they did it.It was an easy fix for us. We were able to simply remove the unused jar from our project and the problem was gone. But, what if we couldn't remove it? Hmm. You can cheat, at least in the IDE. Though I'm sure that might have caused deployment issues. You can re-order the classpath by moving a class up or down in the list. Just click the jar in question and move it below the JDK entry. Voila, it compiles.
Be careful out there. It's a weird classpath world.
Friday, October 3, 2008
Android and sqlite3
Wow. For my new application which will go unnamed at the moment, I learned something very cool.
In the Eclipse Android SDK for Eclipse, there is a Perspective called DDMS. While your emulator (and application) is running, this will let you do all sorts of cool things. You can take a screenshot of what's showing on the phone. You can debug, look at logs, etc. It also shows you the filesystem for your application. Since your application is a its own Linux account, it has its own set of files and applications. And, if you are like mine and have persisted data using the built-in sqlite3 database, the database is also there on the filesystem. If your app is called foo.myapp then it's under /data/data/foo.myapp/databases.
There will be a file that is the name of the database along with any tables.
Let's say your database is called MyDatabase and you have a table, mytable.
Now click on the databases folder and click the action menu item for that view "Pull a file from this device". It will actually copy this whole directory to your local filesystem.
Now, hopefully at this point you are in Linux and already have sqlite3 installed. You do run Ubuntu right? :-)
Bring up a shell. Fire up sqlite3 like so:
That's it. It should list the contents of your table (assuming you have a column named col1). Other than that, it's standard sqlite3 stuff.
There should be a lot of neurons firing right now about what this means. Perhaps involving snycing. You can add files back to the device. And, this sort of thing can be done with a standalone emulator, so no eclipse is required.
Enjoy!
In the Eclipse Android SDK for Eclipse, there is a Perspective called DDMS. While your emulator (and application) is running, this will let you do all sorts of cool things. You can take a screenshot of what's showing on the phone. You can debug, look at logs, etc. It also shows you the filesystem for your application. Since your application is a its own Linux account, it has its own set of files and applications. And, if you are like mine and have persisted data using the built-in sqlite3 database, the database is also there on the filesystem. If your app is called foo.myapp then it's under /data/data/foo.myapp/databases.
There will be a file that is the name of the database along with any tables.
Let's say your database is called MyDatabase and you have a table, mytable.
Now click on the databases folder and click the action menu item for that view "Pull a file from this device". It will actually copy this whole directory to your local filesystem.
Now, hopefully at this point you are in Linux and already have sqlite3 installed. You do run Ubuntu right? :-)
Bring up a shell. Fire up sqlite3 like so:
That's it. It should list the contents of your table (assuming you have a column named col1). Other than that, it's standard sqlite3 stuff.
There should be a lot of neurons firing right now about what this means. Perhaps involving snycing. You can add files back to the device. And, this sort of thing can be done with a standalone emulator, so no eclipse is required.
Enjoy!
Wednesday, June 18, 2008
I love me some Ruby
So, I'm learning Ruby and Rails at home, and I'm absolutely loving it.
I love the little idiomatic stuff that make typing in it so concise.
Let's say that I have a list called mylist. I want to add an object to the list, foo.
In Java, I'd have to go something like this.
In Ruby, it's just this:
It's not earth shattering, but there are a dozen examples like this that I really like. If you understand the symbols and operators of the language, it actually reads just fine. Maybe I'm getting cranky in my old age and not wanting to type out all that stuff as much anymore.
Another perhaps bigger example was the "attr_accessor" convenience method.
What just happened here? For me, the critical part was the getter/setter bits. In Java, I'd have to select a menu option in Eclipse to generate the getter's and setter's for this class. Imagine a class with 10 fields in Java. You are NOT gonna type out those methods.
In the Ruby case, it's just 1 line of code. And, you can add more fields to the same line. "attr_accessor" tells us that what are our accessor methods. Nice!
See also attr_reader and attr_writer which do as you would expect, allowing only read or only write methods.
I love the little idiomatic stuff that make typing in it so concise.
Let's say that I have a list called mylist. I want to add an object to the list, foo.
In Java, I'd have to go something like this.
In Ruby, it's just this:
It's not earth shattering, but there are a dozen examples like this that I really like. If you understand the symbols and operators of the language, it actually reads just fine. Maybe I'm getting cranky in my old age and not wanting to type out all that stuff as much anymore.
Another perhaps bigger example was the "attr_accessor" convenience method.
What just happened here? For me, the critical part was the getter/setter bits. In Java, I'd have to select a menu option in Eclipse to generate the getter's and setter's for this class. Imagine a class with 10 fields in Java. You are NOT gonna type out those methods.
In the Ruby case, it's just 1 line of code. And, you can add more fields to the same line. "attr_accessor" tells us that what are our accessor methods. Nice!
See also attr_reader and attr_writer which do as you would expect, allowing only read or only write methods.
Wednesday, June 11, 2008
MyEclipse Quirk
I discovered a really weird UI quirk with MyEclipse today. I updated a thread on the MyEclipse forum for good measure. But, this is the issue:
I've seen this where case where the Add button on the Manage Deployments dialog is grey or greyed out. It's the weirdest thing. This was happening to me on Ubuntu Linux today but I don't think that matters. Also, I'm using MyEclipse 6.x. And, this also happened to a colleague of mine using Windows a few weeks ago. It was maddening and I couldn't figure it out at the time.
It seems that if the current open project doesn't have focus, this occurs. Make sure to click somewhere on your project in your project explorer. Then click the Deploy button again to bring up the Manage Deployments dialog.
So, to re-create this problem click on a closed project on your package explorer then try to deploy. It should be greyed out.
I don't know if this is really a bug as much as it is a UI quirk?
I've seen this where case where the Add button on the Manage Deployments dialog is grey or greyed out. It's the weirdest thing. This was happening to me on Ubuntu Linux today but I don't think that matters. Also, I'm using MyEclipse 6.x. And, this also happened to a colleague of mine using Windows a few weeks ago. It was maddening and I couldn't figure it out at the time.
It seems that if the current open project doesn't have focus, this occurs. Make sure to click somewhere on your project in your project explorer. Then click the Deploy button again to bring up the Manage Deployments dialog.
So, to re-create this problem click on a closed project on your package explorer then try to deploy. It should be greyed out.
I don't know if this is really a bug as much as it is a UI quirk?
Friday, April 25, 2008
SQL's brain-lock on the development community....
I was reading this blog post by Tim Bray on the subway this morning. It seems so spot on to me. So, I'll link to it now and maybe comment on it later.
By the way, Tim was one of the co-founders of OpenText back in the day.
Tim Bray: Multi-Inflection-Point Alert. The comments are quite insightful as well.
By the way, Tim was one of the co-founders of OpenText back in the day.
Tim Bray: Multi-Inflection-Point Alert. The comments are quite insightful as well.
Wednesday, April 2, 2008
How Fast Can OpenOffice.org Be Extended?
Here's a nice article with code and screenshots on how to extend Open Office using Java. When I was playing around trying to do some stuff with Plucker, I also noticed they have a Java package to handle Palm database files (.pdb). Look around in their repository. You might actually find some useful code.
TDD, yeah you know me
If you've been keeping up with my rants lately, you know that I have become a big advocate of TDD in the last few months. But, it's a practice that's hard to convert people to, including yourself. I wish I could even get to the point with code coverage that I could get to this argument. Alas, I'm not there yet with my current group. Follow the link. There are a lot of good comments related to TDD following the post on Cedric's blog. Like anything, it's not for everyone, or for everything. But, you should at least look at the idea.
Otaku, Cedric's Blog: TDD leads to an architectural meltdown around iteration three
Otaku, Cedric's Blog: TDD leads to an architectural meltdown around iteration three
Subscribe to:
Posts (Atom)