I began studying Android seriously for the first time today, and before being able to test the initial piece of sample code supplied by Google, I ran into two problems that took many hours to solve. Below are the solutions:
1. [posted to Stack Overflow] Initially Google's code would not run, so I updated Eclipse. That led to the error "Dex Loader SecurityException: Unable to find field for dex.jar". There was no obvious difficulty with the upgrade.
After many partial measures, it took the following to get the error to go away:
- deleting both the Tools and current Android API installation, using the Android SDK Manager (followed by reboot);
- deleting the original directory in my filesystem containing the Android SDK files;
- downloading a fresh version of the Android SDK files (http://developer.android.com/sdk/index.html) and specifying its location in filesystem to Eclipse in Preferences=>Android;
- installing fresh versions of both the Tools and current Android API, using the Android SDK Manager (followed by reboot)
I wonder if there is something buggy in the regular updating protocol. If updates go wrong again, I will try this full uninstall and reinstall of the SDK files and ADT Plugin from the outset.
2. The emulator was extremely slow, so I tried connecting my two Android devices (Android OS v. 2.3.4 = API 10, v. 4.0.3 = API 15) to my computer and "registering" them with Eclipse's Android Device Chooser. One has to turn on USB debugging on the phones, but this alone did not make registration possible; neither did rebooting the phones. Registration was possible only after rebooting my Mac.
It's strange to say, but I often find that whatever software problems I am having evaporate near the end of the time I have allotted to work on them. Tonight, as many times before, hours of frustration ended rather suddenly a few minutes before midnight.
I don't understand this phenomenon, but am getting used to it. Getting a little used to it — I never believe it's going to happen again until it does.
Hardware and software involved:
- Mac OS 10.8.2 on 11-inch MacBook Air, Late 2010
- Eclipse Version: Juno Service Release 1
- Build id: 20121004-1855
- Android tools: 21.0.0.v201210310015-519525