Wednesday, 25 September 2013

Intentional or Unintentional Unplugging of Ethernet cable or USB cable while on read or recv linux calls

   A very typical scenario when you are coding on a real-time project which requires high stability and sustainability and in the middle someone comes and pulls your ethernet cable or usb cable (in case of mobile devices). At that time your read / recv calls gets blocked and returns after a very long time.

In Linux or Ubuntu, whenever that happens, you should call two functions which would make your read / recv to come out with an error code and they are as follows:
  • shutdown - API of Linux
  • closesocket - API of Linux.

Tuesday, 17 September 2013

Build Project using NDK

Please follow the below guidelines:
  1. Consider the $PROJECT as the Project Directory, say SampleApplication as my Project.
  2. Create two Directories inside the Project Directory, namely
    1. jni\
    2. code\
  3. Place the Android.mk inside the jni\ directory.
  4. Place the entire code inside the code\ directory.
  5. Open command prompt and go to the $Project directory, then run %NDK_BUILD%, provided you are in windows and you have created an Environment Variable named NDK_BUILD which will be as follows: eg: D:\Backups\Android-NDK\ndk-build.
  6. Build the code in windows by giving %NDK_BUILD%.

Sample Android.mk File

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE            :=     libvncclient
LOCAL_SRC_FILES            :=     <source file names, current directory will be jni>
LOCAL_C_INCLUDES        :=  $(LOCAL_PATH)/include/
LOCAL_CFLAGS            :=    <MACRO DEFINITIONS>
LOCAL_LDLIBS            :=   
LOCAL_SHARED_LIBRARIES     :=   
include $(BUILD_SHARED_LIBRARY)

TADA.......................

Sunday, 15 September 2013

Create JNI File from Java Class file

Create a Simple Java Project as given below

package com.example.helloworld;

public class HelloWorldActivity {

    static {
        System.loadLibrary("hello-jni");
    }
   
    public native String stringFromJNI();

}

Compile it. Say the directory is "D:\Project\J2SE Workspace\HelloWorld\bin\classes", then go to this directory where the package starts for the class file, then give

javah com.example.helloworld.HelloWorldActivity

It will create a JNI class for you with the required functions provided in the Java file.

Thursday, 12 September 2013

Install CDT and ADT for Eclipse

Install the choice of Eclipse you need from the eclipse site.

Currently I had Eclipse Keplar

CDT
Use the Repository as below for getting the CDT plugin.
http://download.eclipse.org/tools/cdt/releases/kepler

Use the above repository URL in
Help -> Install New Software
in the Work With text box paste the above URL and press enter, it will search the site for available plugin and install.

ADT

Use the Repository as below for getting the ADT Plugin.
https://dl-ssl.google.com/android/eclipse/

Use the above repository URL in
Help -> Install New Software
in the Work With text box paste the above URL and press enter, it will search the site for available plugin and install.

Monday, 19 March 2012

build/tools/soslim/soslim.c(123): gelf_getshdr(): invalid operand

Hi Folks,

Today am going to share with you a what I experienced when I was working wih Android NDK. I usually hibernate my work because in every project definitely there will be many files on which we would be working continuously. Hence I again hibernated but suddenly after I logged in I found this problem

build/tools/soslim/soslim.c(123): gelf_getshdr(): invalid operand

I approached my seniors for this error but they were unable to respond back with a solution or reproduce it. So in anger I just closed every terminal and just started the terminal new and built the Android NDK. It just became fine without any error.

So I would like to say that if in the future you experience this problem just close everything and restart it. :)

Thursday, 16 February 2012

How to Log into root account in Ubuntu

I faced the same problem of not able to log into the ubuntu's root account. Ubuntu is more secure and it makes the user to make use of the resources safely, hence instead of providing the su command, it has provided sudo command. Using sudo you could log into the root account as follows:

bash#sudo bash

u get the root access to your new bash shell, now you give


bash#sudo passwd
Enter New Unix Password:
Confirm Password:

And BINGOOOO.... you now made a password for the root account :D enjoy by logging off the current user account and log into the root account with your currently set password :D