» Archive for the 'Uncategorized' Category
Signing Android applications
Saturday, May 15th, 2010 by NikiIn order to install an Android Application onto the emulator or the phone you must first cryptographically sign it. When you do a debug build (using “ant debug”) ant will automatically sign the binary with an auto-generated debug key.
This key is set to expire 365 days after it was auto-generated (the first time you did a debug build). If a debug build fails due to an expired key, you simply need to delete the current debug key and a new one will be auto-generated. To do this, navigate to where the debug key is located and delete it. On Linux and Mac OS X this is ~/.android and the key is the file “debug.keystore”.
Signing your application with a debug key is fine for testing purposes but for release the application should be signed with a unique key that you have generated just for that purpose. If you plan on release the application on the Android Market then the key should also contain correct identifying information (your name or company) and should expire no earlier than October 22, 2033.
To generate a key you need to have the keytool application that come with Java. You need to specify the key-store (the file name), the alias for the key, which algorithm to use (we want RSA) and how long it should be valid for. Let’s create a key stored in the file “release.keystore” with the alias “release” that will be valid for 10,000 days:
niki@redblacktree:~/.android$ keytool -genkey -v -key-store release.keystore -alias release -keyalg RSA -validity 10000
Keytool will then ask you a bunch of questions:
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: Niki Yoshiuchi
What is the name of your organizational unit?
[Unknown]: aplusbi
What is the name of your organization?
[Unknown]: aplusbi
What is the name of your City or Locality?
[Unknown]: New York
What is the name of your State or Province?
[Unknown]: NY
What is the two-letter country code for this unit?
[Unknown]: US
Is CN=Niki Yoshiuchi, OU=aplusbi, O=aplusbi, L=New York, ST=NY, C=US correct?
[no]: y
Generating 1,024 bit RSA key pair and self-signed certificate (SHA1withRSA) with a validity of 10,000 days
for: CN=Niki Yoshiuchi, OU=aplusbi, O=aplusbi, L=New York, ST=NY, C=US
Enter key password for
(RETURN if same as keystore password):
[Storing release.keystore]
And you’re done! You’ll notice that I ran keytool out of the ~/.android directory so that release.keystore is located in the same place as debug.keystore.
Now onto signing applications. Let’s go back to our Hello Android project and do a release build:
niki@redblacktree:~/projects/android/hello$ ant release
Once this has finished there should be a new apk located in the bin directory called “HelloAndroid-unsigned.apk”. We need to sign it with the key we created earlier using jarsigner:
niki@redblacktree:~/projects/android/hello$ jarsigner -keystore ~/.android/release.keystore HelloAndroid-unsigned.apk release
And now “HelloAndroid-unsigned.apk” has been signed. It can now be installed using adb.
The pocketknife paradox
Saturday, April 18th, 2009 by NikiA few months ago I was having a discussion with a few friends of mine and the subject of social awkwardness as it applies to telephone conversations arose. I am in many ways a stereotypical nerd and I am no stranger to social awkwardness. I have grown out of the worst of it, but telephone calls are still difficult for me.
One of my friends could not believe that anyone could have trouble making a phone call or talking to someone on the phone. At the time he worked in tech support and answered phones for a living. It came very naturally to him and he had trouble believing that he had some special skill that made him good at his job.
Eventually I came to realize how his attitude mirrored my own, albeit about entirely different subjects. I often have trouble understanding how some people are unable to understand basic logic or simple math. It’s frustrating to encounter an otherwise intelligent person who barely understand a concept as simple as say, division. There are certain skills that I possess that are “innate” (I don’t know if it’s genetic or environmental but it doesn’t matter either way) and that I take for granted. These skills are so simple for me that I have to fight the temptation to write off as stupid people who have difficulty with the same tasks.
I call this the “pocketknife paradox” – I have a lock-back pocketknife that I typically carry on me. I have observed that somewhere around half (and I believe it to be greater than half) of the people that I have lent it to are unable to figure out how to close it. The mechanism to lock the knife in the open position is so intuitive to me that I forget that many people don’t observe things the same way I do.