Android

Setup android testing development with jenkins on Windows 8

25 Sep , 2013  

I assume we already have android environment works in our Windows 8. Don’t forget to add “sdktools” into windows global environment variable PATH. So, we can run “android” commmand from DOS. Also, make sure there already ANDROID_HOME that pointing into sdk folder.

First, we should have ant installed. We can download it from http://ant.apache.org/bindownload.cgi.
Download binary and extract it. After that, try to add it into global environment variable.
It will make “ant” command executable from DOS.

In project folder

1
ant clean debug

I got error:

1
2
3
BUILD FAILED
C:UsersyodiDownloadseclipse-androidsdktoolsantbuild.xml:466: Invalid fil
e: D:Mobileappgoogle-play-services_libbuild.xml

What i need here is go to that folder and do “android update project -p .”. Keep doing this for another conflicted libraries. I also got error duplicate android-support-v4.jar. This error occured because different SHA1 android-support-v4.jar in your project and libraries. Make them same by copy android-support-v4.jar from your project and replace all libraries android-support-v4.jar with it.

Now, we are ready to run “ant clean debug” in project folder. Later, we can run “ant clean emma debug install test” in test folder.

Android

Android window leak

20 Sep , 2013  

This issue appear when trying to leave Activity but Dialog still hanging there. Dialog should be closed before leaving Activity.

What a cases that lead to android window leak? Simple, we show Dialog to choose take picture from Camera or Gallery.
If we choose Camera, then it will redirect to Camera MEDIA activity.

1
2
3
4
Uri outputFileUri = Uri.fromFile(newfile);
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(cameraIntent, TAKE_PHOTO_CODE);

This will lead to window leak. Remember to close everything by :


Uri outputFileUri = Uri.fromFile(newfile);
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(cameraIntent, TAKE_PHOTO_CODE);
finish();