Pages

Thursday, July 31, 2014

Use Jekyll to create a blog and host it on Github

Github is an attractive option for hosting a technical blog. The process is as simple as creating a repository, and adding index.html to it. Details can be looked up at https://pages.github.com/. Github uses Jekyll to generate the site. Jekyll is a simple, blog aware, static site generator. Using markup for the blog entries is one of the features of Jekyll. The installation can be done via gem ruby tool. http://jekyllrb.com/docs/quickstart/
Once installed, follow the following steps:
  • Clone the github page repository.
    git clone abc.github.io
  • Create a new file in the local git repository.
    touch Gemfile
  • Edit the file and put the following lines in it.
    source 'https://rubygems.org'
    gem 'github-pages'
  • Install Bundler http://bundler.io/
    gem install bundler
    bundle install
  • To run Jekyll with Bundler, issue the following command in the root repository.
    bundle exec jekyll serve
  • The site should now be available at:
    http://localhost:4000
More can be read about working with Jekyll at http://jekyllrb.com/docs/structure/. A very good example can be found at https://github.com/maciakl/Sample-Jekyll-Site/.

Wednesday, July 30, 2014

Fix INSTALL_FAILED_INSUFFICIENT_STORAGE while installing the Android App during development phase

On a device like Samsung Y Duos with only 160MB of internal memory, it is common that the app gets installed first time but when you reinstall the app, you get:

Failure [INSTALL_FAILED_INSUFFICIENT_STORAGE]

This is an annoyance when an IDE is being used to deploy and redeploy app while in development.

Usually the IDE does the following to install the package:

adb shell "pm install -r '/data/local/tmp/com.your.package'"

This results in the INSTALL_FAILED_INSUFFICIENT_STORAGE error if the app is already installed on the device. A simple solution to this is to uninstall the app first through command line (uninstalling does not work when using Application manager in phone's settings):

adb shell "pm uninstall com.your.package"

And once the app is uninstalled, then either do a command line install or let the IDE handle installation.

adb install YOUR_APK

Monday, July 21, 2014

Check Google Cloud Messaging (GCM) Client for Android using Curl

This post deals with testing a GCM Client without implementing a formal backend server. It uses the unix command line tool curl to send messages to the devices registered with GCM. Please note that this is not an end-to-end tutorial on how to implement GCM in your apps. If you want more information on the topic, please refer to http://developer.android.com/google/gcm/index.html.
You can run the following script on terminal to send messages to your test device.
curl -X POST \
-H "Authorization: key= YOUR_AUTHORIZATION_KEY" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [
"YOUR_DEVICE_TOKEN"
],
"data": {
"message": "YOUR_MESSAGE"
}
}' \
https://android.googleapis.com/gcm/send

YOUR_AUTHORIZATION_KEY:



YOUR_DEVICE_TOKEN: Token received when the client device registers with GCM server.

YOUR_MESSAGE: Message to send.

Happy messaging!