Archive for the ‘Tips’ tag
/* .DS_Store file in “res” directory */
Yesterday, I wanted to see the list of internal icon resources of Android SDK, so I put a dummy ImageView widget to a screen in Graphical Layout and it opens the dialog named “Resource Chooser”. But it causes crash and freeze of Eclipse IDE suddenly. Why? When I previously used Resource Chooser dialog, it works perfect without any error.
In short: The cause is .DS_Store file in “res” directory (incl. all sub directories)
ADT plugin tries to read something from .DS_Store file in “res” directory (especially “drawable” directory) and causes crash. Okay, so I just remove it using Finder… WAIT! If you remove .DS_Store file using Finder, Finder will generate .DS_Store file again. Really scare infinite-loop.
Use Terminal. Remove them using “rm” command from Terminal application. While you’re using Resource Chooser dialog, don’t touch the Finder app which shows “res” directory or its children.
/* BroadcastReceiver */
I wanted to send and receive my own broadcast intent, so I defined MyBroadcastReceiver class in MyAndroidActivity class which is the main activity class launched by Android. Since Java language doesn’t allow to define two or more public classes in same Java source file, I declared MyBroadcastReceiver class with no modifier (package-private). As a result, I got cryptic exception “IllegalAccessException”:
DalvikVM[localhost:8600] Thread [<1> main] (Suspended (exception RuntimeException)) ActivityThread.handleReceiver(ActivityThread$ReceiverData) line: 1773 ActivityThread.access$2400(ActivityThread, ActivityThread$ReceiverData) line: 117 ActivityThread$H.handleMessage(Message) line: 981 ActivityThread$H(Handler).dispatchMessage(Message) line: 99 Looper.loop() line: 130 ActivityThread.main(String) line: 3683 Method.invokeNative(Object, Object, Class, Class, Class, int, boolean) line: not available [native method] Method.invoke(Object, Object...) line: 507 ZygoteInit$MethodAndArgsCaller.run() line: 839 ZygoteInit.main(String) line: 597 NativeStart.main(String) line: not available [native method] Thread [<8> Binder Thread #2] (Running) Thread [<7> Binder Thread #1] (Running)
After a bit struggling, I found out the answer: subclass of BroadcastReceiver must be declared with public modifier
A subclass of BroadcastReceiver is called from Android system, so I had to define it with public modifier. This means you can’t define it in same Java source file. I tried to define it as public inner class of MyAndroidActivity but failed.
/* OMG… */
I have been bothering that Adobe Illustrator always crashes on both Windows XP and 7 when I save the file with AI (Adobe Illustrator) extension to the local disk. Finally, I dug up the way to resolve that annoying problem; just enable Print Spooler service! I can’t believe this… but it’s true. You can enable that service from: Control Panel -> Administrative Tools -> Services, then change “Startup Type” of Print Spooler service to “Automatic”. Of course, you should enable it manually right now!
Thanks for great tip: http://forums.majorgeeks.com/showthread.php?p=1346117