Technical

Learning Android : Why I moved away from Eclipse

0

So, after a very long break, I started back with getting familiar with Android development… Felt happy seeing that Google has made a lot of improvements / features in the ADT. But, everything evaporated when I tried to debug an app on my machine, and got this error: “Android Packaging Problem: resources.ap_ does not exist”. I tried cleaning the project, restarted Eclipse, and re-creating the Eclipse project and this error didn’t go away… Googling it also didn’t help much… Then, I went to sleep….

The next day, to my surprise, there was no error and I was able to debug my app, at last… But, it didn’t last long… After 3 hours, the same error is back…. It looked like this ADT solves everything else (Resource Editors, WYSIWYG Editor etc.) but the basic task it is supposed to do (Basic compiling / packaging / debugging)…

Now that perfect mood is set to go hunting for a new and *reliable* IDE, I searched in stackoverflow.com for answers… Found some thread saying IntelliJ IDEA is good…. So, downloaded it, downloaded its dependencies (JSDK 1.6) and installed them… And there is no turning back… I don’t miss the resource.ap_ error at all…

The Pros of IDEA:

  1. Reliable (unlike ADT for Eclipse) at compiling and packaging…
  2. Supports the Android “Library” projects also… (Tried it with GreenDroid, and worked without a glitch)
  3. Import Eclipse projects directly…
  4. Integrated github support (and a few more Version Controls)
  5. Decent enough features, for Refactoring, Imports optimization, Code completion etc.

The Cons:

This could become a big list, but the reliability when compared to Eclipse beats everything in the below list combined..at least for me…

  1. Page Scrolling – Cannot use the Mouse Scroll.. Need to click on scrollbar and scroll it down.. :(
  2. Logcat sucks!! The one in Eclipse is hell lot better.. Seriously needs Filter by Application, Colored text based on log level, and saved searches.. A simple textarea doesn’t justify such an important feature..
  3. The keyboard shortcuts are completely different from Eclipse.. Why doesn’t IDEs come with keyboard binding set of other IDEs that user can choose to use? :(
  4. Memory hogger, seems to be more than Eclipse.. Could it be because of Swing & Java?
  5. Basic XML Editor – There are no Android Resource Editors…. I prefer to write XML files by hand, though…
  6. Some code warnings may misguide you.. It keeps telling me that Cursor cannot be NULL, though I have personally seen cases where it will be…

In simpler words, IDEA may not be as good as Eclipse in general, but for Android development, it is certainly a better choice… at least for now..

Atleast, you’ll know you are frustrated not because of IDE… (Trust me, frustration because of an IDE, instead of logic/code isn’t even worth trying to know.. )

Browser Wars: Learning from each other

0

The most popular browsers from the country I come from (where Mac is rare) are Google Chrome, Mozilla Firefox & Microsoft Internet Explorer. Like any other browser, these all have the same goal – to make browsing experience richer & better. Yet, there are a lot of differences in their ways and some are better than other in some ways.

If I ever have to make a generic purpose browser, I’d certainly pick good (for inclusion) & bad (for exclusion) things from the current browsers.

Google Chrome:

The recent one and certainly a game changer. It has improved the user expectations from a browser by 100x.

The Good:

  • The crashless browser -  protect the user even from the crashes in external plug-ins (Thankfully, Firefox also implemented out-of-box plugins)
  • Faster startup time – Do things that are only absolutely needed. Nothing more. Defer everything else, to post-startup (in parallel with the user’s browsing).
  • Sandboxing – Whatever you do on web stays on web. Protect the machine from all the various security issues.
  • Explicit permissions listed for Extensions – user must know what an extension is capable of (despite of what it claims to do)
  • Silent updation: Push updates only when it is good for users. Then, who would say “no” to better browsing experience? So, there is no point in showing an annoying dialog “Updates Available” when you already know the user clicks “yes”.
  • Incognito Mode starts a new session without closing the current session (sadly, Firefox does that)

The Bad:

  • Weakest & the most limited extension model – So limited that it may give you a feeling that the word “extension” doesn’t suit it.
  • Still an immature platform for developers. Extension Model hasn’t moved but the other parts (rendering, UI etc.) are moving forward at a very fast pace. Even, many bugs in the chrome extensions are not getting fixed for many months.
Mozilla Firefox

The Good:

  • Super cool extension model. There is almost nothing that can’t be done by the addons. And, XPCOM works across all the platforms.
  • Known to be the developer-friendly browser from long time. One of the early browsers that emphasized on standards and innovation from its early days.

The Bad:

  • Known to be memory hog. Not efficient at Memory management. Have issues with Intel’s hyperthreading.
  • MaxVersion in addons is mandatory and is limited to current version (you can’t just use * for maxversion). The only issue with this is each and every addon is to be updated (you add features or not) with every major version release (which is once in 12 weeks as of now).
  • Private browsing closes the current session and starts a new one. After closing private session, it restores the earlier session. This means you can’t do both (with default command line options)
  • Every extension have complete control (including a binary component), because of lack of a permission model. You can never trust an extension because of this!
Internet Explorer

The Good:

  • Its never late to catch up with the standards, speed & security (with IE 9 & IE 10)
  • Native 64-bit for 64-bit OS. (I can’t believe Firefox and Chrome do not have them for Windows)

The Bad:

  • Still maintains the completely idiotic ‘Quirks Mode’. I don’t see the greater cause of maintaining a version which is full of bugs, extremely slow and follows no standards, and also all developers hate it.
  • Extension Model – Its a big pain. You need to be comfortable with COM to get started with. Its much comfortable to think addons don’t exist at all for this version.
  • Supports ActiveX plugins when the whole world uses NPAPI plugins.

Disclaimer: All the above are my own thoughts, and I’ve to confess I haven’t researched every point. So, not all the above may be true, but is to the best of my knowledge.

5 Reasons I dislike Flash

0

The times have changed to where we spend most of our lives on the web. But, web is far from perfect. It has annoyances lurking around at every corner. Most of the times I get annoyed is because of the bad code (in HTML, CSS, Javascript) by the developers. The next big annoyance is from Flash content, but I can’t blame the content developers for their code. Its the design issue of the Flash runtime itself…

The top 5 things in Flash that annoys me daily:

  1. Browser shortcuts (like, Ctrl+W, Ctrl+T) do not work when focused on flash elements, since it consumes all the keyboard events. I’d expect it to at least pass them to browser if it doesn’t handle a key event, but it doesn’t even bother.
  2. Zoom doesn’t work – Ctrl++, Ctrl+- are useless. You have to read the content in SWF in the published size itself. You cannot increase or decrease it size. :(
  3. Middle Click doesn’t work – I can’t open a link in new tabs. Opening links in new tabs from SWF is a small-size challenge.
  4. I can’t find the text I’m looking for with Ctrl + F. You can’t just search in Flash content, unless the SWF itself contains a search box & search implementation.
  5. Its pretty famous & is gonna stay there longer. And the worst part – everyone uses it in their site, though there is absolutely no need for it (making my browsing experience annoying) :(

Disclaimer: The above view is completely personal and has absolutely nothing to do with anything (including friends & employer also) else.

Firefox Addons: Little Housekeeping Tips

0

I’m working on a Firefox addon in the last few weeks and this is my 1st experience with Firefox addons. During my tiny experience, I came across some of those little things that helps you when you’re in trouble & here I’m writing about those simple tips. Of course, I mixed some changes in Gecko 2.0 also along with these….

I know these are very basic, and almost everyone who worked on the addons might be knowing them, but hey, didn’t I mention you that this is my first encounter with building firefox addon?

How can I be sure if a Binary XPCOM component is loaded / attempted to load from Firefox?

Close all Firefox windows and run the following from command line:

set NSPR_LOG_MODULES=all:5
set NSPR_LOG_FILE=c:\ff.log
C:\Program Files\Mozilla Firefox\firefox.exe

What does it do? Line 1 sets the modules to load & the log level. In the above commands, we are asking to log all modules with log level 5 (meaning all logs). Line 2 sets the path to log file. Now, just launch the Firefox from command line (so that the variables are set)

Troubleshooting Tip: Do not use quotes around the log file name, like set NSPR_LOG_FILE=”C:\ff.log”. I tried it the 1st time and it doesn’t work.

References: Troubleshooting XPCOM components registration, NSPR Logging

How can I sure if an XPCOM component is successfully registered?

This works for both binary & JS components.

Enable Chrome errors in Error Console, if you haven’t done already! To enable, set javascript.options.showInConsole to true in about:config preferences.

Open Error Console (Ctrl+Shift+J)

Evaluate Components.classes["components-contract-id"].name. Use with the components’ contract id.

If it gives no error, the component is successfully registered.

References:  javascript.options.showInConsole, Troubleshooting XPCOM components registration

How to log errors from the XPCOM components?

This is simple thing, and I realized a bit late about it. This is currently how I’m debugging my components (need to see if there is a better way). You can report error messages to the Error Console with:

Components.utils.reportError(“This is the description of the error”);

References: Error Console

nsIConsoleService

The inconvenience with the reportError API is that it logs all messages as errors. To log at various levels (debug / warning / info), we can use the nsIConsoleService. The logStringMessage() function of this service looks very handy.

I haven’t used it yet, so I cannot give any more information on this!

References: nsIConsoleService Reference

UnPack option

If you are using binary components in the addon, you MUST set the unpack value to true in install.rdf file.

References: unpack in Install Manifests

Bootstrap Addons

This feature introduced in Gecko 2.0 answers one of my long-time questions – Why should I restart the browser everytime I add / update / disable / remove an addon?

Though this feature is good, it looks complicated to do all the manual work. I’ve skipped trying this feature for now, but I’ll look into this some other time.

References: Bootstrapped Extensions

Gecko 2.0 XPCOM Changes

Though there are many changes, I’m listing the few which I came across.

  • Javascript component must export NSGetFactory() instead of NSGetModule() function. Binary component must export NSModule() instead of NSGetModule() function. I’ve explained this in detail in the next section.
  • Components in components/ folder are no longer auto-registered & auto-loaded. Components registration will be done through the manifest file.
  • Category Registrations are done through manifest file. Also, category names are modified.
  • You’ll have to use the XULRunner SDK 2.0 for Gecko 2.0

Troubleshooting Tip: Use the sample CPP file (from the references) to get started for binary components. I got a few compilation errors initially, and then I has to add MOZ_NO_MOZALLOC to preprocessor definitions as read somewhere, and it worked..

References: XPCOM Changes in Gecko 2.0, nsSampleModule.cpp source code

Component Registration in Firefox 4.0

All the components to be registered has to mentioned in the chrome.manifest file.

  • All the interfaces (xpt files) are to be registered using interfaces command
  • A JS component must use component command. It needs to mention its class id also. The contract id can be assigned to this JS component by a separate contract command.
  • A binary component can be registered with binary-component command. A binary component registration need not specify any class-id or contract-id in the manifest file, since they are available through the exported NSModule() function.

References: Chrome Registration

If you have felt all the content is copied from somewhere, its ok because its true. I’ve learned many things from MDC itself, I’m just aggregating those things here!!

If I’ve got something wrong in here, please do mention them in the comments as I have to correct them in the post as well as in my mind…

 

Troubleshooting XPCOM components registration

 

Debug PHP: Setup

0

Okay! I forgot how to set up debug for my PHP, so I had trouble today trying to set it up today and had to spend about an hour to do so… So, I decided I should note it down for future reference and hence I’m here now!

Tools: PHPEclipse, PHP 5.3.3, XDebug

  1. Make a PHP file with content as <?php echo phpinfo(); ?> and browse the page on localhost.
  2. Copy the source of the above page from the browser and paste it in http://xdebug.org/find-binary.php and click “Analyze my phpinfo() output”. This step will give you tailored instructions on how to setup, especially points to the right DLL to use.
  3. Be careful with the editing php.ini file. Prefer to add the zend_extension line at the top of the file. (It doesn’t work if its the last line)
  4. And start debugging from the Eclipse IDE !!
Go to Top