Friday, June 3, 2011

R.java: No such file or directory


solution:




  1. run this in a terminal:
    rm ~/.android/debug.keystore


  2. rebuild your project: go to Project --> Clean --> Clean projects selected below --> check your project --> OK







backstory:



okay, so I was tinkering with android today in Eclipse, and all of a sudden, my android project shows it has an error. not on any particular file, but on the project itself. normally when I get random errors, I select the project and go to Project --> Clean. today, that didn't work.

I wasn't seeing anything helpful in the console. after cleaning the project, I saw this in the console:

[2011-06-03 15:21:52 - android_test] ERROR: Unable to open class file /home/user/workspace/android_test/gen/us/test/test/R.java: No such file or directory

that was weird, because the file existed. so I went ahead and deleted the gen folder and rebuilt the project (which is what the clean command basically does), and still got the same error.

thinking my eclipse installation was corrupted, but too lazy to reinstall, I restored backups of various folders. no dice. I reinstalled the android SDK tools. nope. I checked permissions, tried reimporting my project, even tried creating a new project, and nothing worked.

finally, out of desperation, I deleted the .android folder in my home directory. success! after looking further into the issue, I found the solution here:

http://stackoverflow.com/q/2194808/399105

although what frustrates me the most is I never saw any errors related to the debug certificate.

of course, wanting to know the details, I ran the keytool command on my backup of the old keystore (the keystore password is "android"):

keytool -list -keystore ~/Desktop/android-backup/debug.keystore -v
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: androiddebugkey
Creation date: Jun 3, 2010
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 4c07f835
Valid from: Thu Jun 03 13:45:09 CDT 2010 until: Fri Jun 03 13:45:09 CDT 2011
Certificate fingerprints:
MD5: 49:56:C0:A8:02:9F:38:97:81:D1:22:BA:F3:50:17:23
SHA1: 3D:E8:57:A1:87:97:45:EA:AD:E2:03:66:29:3A:36:DE:9F:F5:35:43
Signature algorithm name: SHA1withRSA
Version: 3


...and there's my exact problem: it looks like the debug certificate generated by the Android SDK is only good for a year.

oh well, at least I'm back in business :)

Edit:

argh, I just ran into this again, but it took me a while to find it because this time the error was "Your project contains error(s), please fix them before running your application." selecting the project, then going to Window --> Show View --> Problems gave me the error "R cannot be resolved to a variable". gotta love these detailed errors...

well I shouldn't run into this again because Google's changed it so now my debug certificate is good for 30 years :)

Wednesday, June 1, 2011

nullege.com: search python source code

the title sums it up pretty well. I know you can find just about anything using google, but supposedly nullege.com is a little smarter when it comes to python. it's a cool idea, at any rate. I haven't had a need to try it out yet, but I'm sure I will before long:


http://nullege.com/