Search this site:


Android 3.0 (Honeycomb) SDK Upgrade Issues

Android 3.0 SDK Preview was released some days ago. I didn't have time play with it until just now.

In fact every time I upgrade the SDK, I was prompted this error:
A folder failed to be renamed or moved. On Windows this typically means that a program is using that folder (for example Windows Explorer.) Please close all running programs that may be locking the directory 'D:\Android\android-sdk-windows\tools' and try again.

Well, it's really ironic that the program locking that directory is the Java.exe started by the SDK Manager. I noticed this issue long ago but didn't able to find a fix. What I did for all my previous upgrade was:
  1. manually rename the tools folder to tools.old
  2. CD into the tools.old folder
  3. run the command: android.bat update sdk
This workaround did work, but just a bit troublesome. I am enough with this error message and wonder why the problem hasn't been fixed for so many releases. I can't be the only person encountering the problem, right?

Then I've found issue 4410 at the Android project. It seems that many other else were encountering the problem because of Anti-virus. Unfortunately it's the SDK Manager.exe in my case as said above. Luckily I spotted comment #67 and #73 which tell the real problem. The SDK Manager.exe actually runs tools\android.bat internally to for upgrading the SDK.

Looking into the file, you will know that the following code will be executed before upgrading SDK:
if "%1 %2"=="update sdk" goto StartUi

if not "%1"=="" goto EndTempCopy
echo [INFO] Starting Android SDK and AVD Manager

rem We're now going to create a temp dir to hold all the Jar files needed
rem to run the android tool, copy them in the temp dir and finally execute
rem from that path. We do this only when the launcher is run without
rem arguments, to display the SDK Updater UI. This allows the updater to
rem update the tools directory where the updater itself is located.

set tmp_dir=%TEMP%\temp-android-tool
xcopy %swt_path% %tmp_dir%\%swt_path% /I /E /C /G /R /Y /Q > nul
copy /B /D /Y lib\androidprefs.jar %tmp_dir%\lib\ > nul
copy /B /D /Y lib\org.eclipse.* %tmp_dir%\lib\ > nul
copy /B /D /Y lib\sdk* %tmp_dir%\lib\ > nul
copy /B /D /Y lib\commons-compress* %tmp_dir%\lib\ > nul

rem jar_path and swt_path are relative to PWD so we don't need to adjust them, just change dirs.
set tools_dir=%cd%
cd %tmp_dir%


Basically the script will create a temp directory containing the necessary JAR files for upgrading. This makes absolute sense as an approach avoiding file locking issues. However, there is a tiny little bugs here. Unlike *nix based OS, Windows get a drive scheme in which each drive is assigned a different letter (C:, D:, etc). The cd command just change the current directory without changing the drive for you. So, if didn't installed the SDK in C:, you probably will have problem here like I do. It is becase the %TEMP% environment variable is by default set to a folder under your home directory (or user profile folder in Windows language). Unless you or your administrator has configure explicitly, it should be at somewhere like i.e. C:\Documents and Settings\yourname or C:\Users\yourname. So if you have installed the Android SDK in any other drives than the one of your profile locates, the cd %tmp_dir% command will fail (yes, it still returns 0, but it's just not doing what it's supposed to do). As a result, the JAR files in the original SDK folder will be used instead of the temporary one - that's why the folder was locked and the upgrade failed.

Solution to this is to change the line (line #65) in android.bat to cd /d %tmp_dir%. Interestingly, from the online Android source repository, the issue has already been fixed. It might be the case that if you upgrade from previous version your android.bat was updated. So either fix it manually or have the whole SDK re-installed :)

BTW, there is another issue installing Honeycomb SDK:
Downloading SDK Platform Android Honeycomb Preview, revision 1
File not found:
The file seems to be removed by Google since this weekend (Jan 29), but why? You can join the discussion here. You can probably find someone sharing the file in the Internet, but you warned: Install from unofficial sources at your own risk.

Update @2011-02-01 03:46 GMT+8:
It's fixed! via @AndroidDev


Facebook Hacker Cup

The Qualification round of Facebook Hacker Cup is happening now.

The Facebook Hacker Cup is an annual worldwide programming competition where hackers compete against each other for fame, fortune, glory and a shot at the coveted Hacker Cup.

I joined the contest. I do not aim at any of the fame, fortune, nor the glory from this event. Instead, I fight for the event t-shirt :)

Well, but there seem to be lots of complaints (a blog post was written as a summary of failures) on this completion. I agree to some of them, while I think some others may not be that valid.

IMHO, the main failures are:
  1. Instructions were not clear enough. First of all is the event time, they were mentioned in different part of the event page but they are inconsistence to each other. And Facebook doesn't handle timezone very well as usual. Secondly, the contest rules is only available in the FAQs page of the event. Many of the important information (e.g. the important 6-min time limits, scoring, what to be submitted as answer) are indeed documented there. Yet the participants have responsibility to read that FAQ page before the contest begins, I guess not many of them really did. The page is not obvious enough for most of the participants to find out. I think Facebook should do a little favor by linking this page from the question pages.
    Update (2011-01-09 02:14 GMT+8): OK I missed something important here. And I admit my fault saying that no clarification was made. The organizer replied to one of their own post and did clarify one important fact:

    This is completely inconsistent with the FAQ page which said that you have to "submit the output (along with your source code)". So this implies that the participants are supposed to filter all the SPAMssssssssss and spot this important clarification in the official pages! Probably this is part of the challenge too!!! WOW!!!
  2. Slowness of the contest system. Well, I really think Facebook should be considerate to those with slow (or not fast) Internet connection, and they should also estimate the huge load it might have on the contest system during the game. Many have reported that after they successfully get the download file, they only have little time left in that 6-min time limit for submitting the answer. Although
  3. The event page was basically unmanaged. I don't see any official responses or clarifications regarding to user's the from Facebook after the game started. There were tons of SPAMssssssssssssssss on event page, well, might be the organizing team would like to be align with their corporate image -yes, Facebook is always full of SPAM.
  4. No feedback after submissions. Although the FAQ page says clearly that results would be known after 72 hours, they display a scoreboard showing only top 10. This might be the real score board used in the coming rounds. However for this qualification round it's almost meaningless. Ranks are not important (at least it is not said to be) to be qualified. We just need to answer at least one questions correctly. So, probably the most important information for us is whether we have submitted the question successfully. There was an entry showing our own rank before we did any submission, but was gone after we did any (probably because we are out of the top 10 rank). As the score was calculated based on the time elapsed from the contest start time, and totally unrelated to when you start the challenge, late player can never pass the first 10 submitting all the 10 questions.
  5. Bugs! Lots of bugs! There were lots of bug reports like submissions cannot be done, timer is going wrong, and etc. Someone even reported that the 6-min time limit can be somehow bypassed too (yet not confirmed). Personally I found some of pages never finish loading. Also I noticed that someone has made 4 submissions despite the fact that there were only 3 problems:

    I have ever thought that it was a challenger for real hackers just like what the game was named, and planned to start finding the hidden 4th questions. However later I saw that the one doing the 4 submissions asked in the event page and I know it's a bug too...
Well, maybe Facebook do all these on purpose, so as to decrease the num of participants in the real online rounds, LOL... But anyway all these problem make the event not really enjoying. Agree with many people's saying, Facebook has really a lot to learn from other online programming contest like Google Code Jam, Top Coder or even the UVA judge.

But to be fair, some of the complaints were not really valid. For example, I saw a lot of participants, probably Windows users, yelling that the input file they downloaded was a long sequence of digits only and totally doesn't look like the sample input. Well. I humbly guess every developers with little experiences should know what's going on: it's the line break issue that different platforms (Windows, *nix, etc) are using different line break sequences. How dare anyone names himself/herself to be a hacker without knowing this. Also, the input file is not for you to read, but your program, and indeed that "long sequence" is completely okay to your program if you has written it correctly.

Anyway, I, like many other participants, am quite disappointed on the organization of the game. I think it might not worth me spending too much time on it. As a result, I only tried to submit one question and I am calling it a day. After all I just need one correct answer to be qualified. And I am confident on my submitted answers is the correct one. See you all in the online round 1 if the submission was done successfully.