Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Wednesday, February 27, 2013

Connecting MK808 device to ADB using the bridge and OEM USB Drivers


MK808 is a very cheap and handy Android device to play around. Connected to an HDMI monitor, we can easily run Android applications on this device. Before starting, we need to first connect MK808 to the ADB so that we can install/run/debug applications. OEM drivers provided by Google is not sufficient to connect the MK808 device to the ADB. After installing the OEM drivers, please follow the below steps

Get Bitmap image from a YUV in Android


Android Camera preview image is in YUV format. The YUV byte[] will have gray image in the first width*height bytes and color information next. For processing preview image without taking picture from Camera using Camera.takePicture method, mostly we need to convert the YUV byte[] into a Bitmap. Following code will help do that

Saturday, October 27, 2012

EXCEPTION_ACCESS_VIOLATION while using JavaCV Facerecognizer class


The below error while executing JavaCV code happen mostly when you try to invoke a method on a non-existing pointer.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000007feea1adf5f, pid=10548, tid=8644
#
# JRE version: 7.0_07-b11
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.3-b01 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [jniopencv_contrib.dll+0xdf5f]
#

We need to understand that JavaCV is a JNI wrapper for OpenCV and other similar native libraries. The objects returned using these methods work a bit different from the normal java objects. The above error happens mainly due to trying to operate on a pointer that no longer exists.
Please refer to the below class, for example

Monday, July 2, 2012

Creating xxx.activity.out.xml and failing with Error in an XML file: aborting build.

It was very annoying when I created a basic Android activity (say activity_test.xml) and tried to run in emulator it fails with an error message stating "Error in an XML file: aborting build."

When you look in editor, you can see that it created a new blank file named activity_test.out.xml and it has an error "No XML content. Please add a root view or layout to your document."

I started playing around a little and found  that the root cause of this issue is more of an Eclipse pattern, not any error. When you click the "Run" button in Eclipse, it uses the default launch configuration registered for the selected file. What is happening is, the selected file happens to be the layout file activity_text.xml and Eclipse launches an XSL launch configuration and it fails.

Two ways to fix this issue is listed below

Sunday, February 5, 2012

How to resolve "Error executing aapt. Please check aapt is present at xxxxxx folder"

I have Eclipse Helios running on 64 bit Ubuntu and I was getting the error message "Error executing aapt. Please check aapt is present at xxxxxx folder" when I tried to compile the Android project. With a little R&D I found that this error happens because, when we install 64 bit Android libraries, there are few 32 bit libraries that we need to install manually.

To get rid of this error, we need to install the 32 bit libraries by executing the below command

First navigate to the folder where you have installed the Android SDK. 
cd /usr/lib/android-sdk-linux/

Now run apt-get to install the 32 bit libraries
sudo apt-get install ia32-libs

Once the install is complete, restart Eclipse and you should be good to go.

Saturday, January 28, 2012

An easy way to add a new Activity in an Android application when using Eclipse

Adding an Activity in an Android application is very simple and straight forward. Activity classes can be created by extending android.app.Activity class and overriding each methods manually. If you do not want to type in all these code manually, there is an easy way to create new Activity when using Eclipse. Eclipse UI provides a very easy and fast way to create new activities.The generated class can also have the code that overrides all the methods from the Activity class, already inserted for you. Here is how we do it.

Passing dynamic data from one Activity to another Activity using Bundle in Android applications

One of the basic requirement in any Android application development is the ability to navigate to one Activity from another Activity on an action or event. Also, in most of the cases, we would want to pass data from the source activity to the destination activity.  If the number of parameters that need to be passed from one activity to another is static and is known during compile time, we can use Intent.putExtra(key, value) method to pass the data. But when the parameters are unknown at compile time and are dynamic in nature, we cannot set the values at compile time directly to the Intent. In this case we will use Bundles. Let us discuss how we can achieve this when we develop Android applications using Eclipse.

Sunday, January 22, 2012

Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder.

While using Eclipse for Android development, you can create a new Android Virtual Device by clicking Window -> AVD Manager  and by clicking new button. If you are getting the error message "Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder." when trying to create an AVD for target platform 4.0.3, here is what you should do.

This error is happening because the location of userdata.img file has changed since Android 4 (API Level 14). So we need to reinstall the ARM EABI package. Follow the below steps


Blog Archive