Showing posts with label software development. Show all posts
Showing posts with label software development. Show all posts

Tuesday, December 18, 2012

Android building unsigned APK

Just a small Android development tip:

The Android export wizard that comes with Eclipse allows you to build the "release" APK of your application but expects you to have the signing keys at the time of the build, otherwise it doesn't allow to proceed. Sometimes you just need to send the unsigned APK to your client and allow them to sign it later.

The easiest way to accomplish that at the moment is to do the build with Ant (build.xml).
In order to generate the build.xml file you can run the following command in your application directory:
android update project --path .

This will create the build.xml file for you project. Then run:
ant release

and this will create the -release-unsigned.apk in your bin directory.
Sometimes (most of the time) the android tool doesn't pick the right name for the project and you might   end up with something like MainActivity-release-unsigned.apk, in that case just edit the project name property in the build.xml.

Note that if your app depends on the other library projects, then these also need to have the build.xml generated for them.

Monday, December 10, 2012

Gitk on Mac OS X tip

Just a quick tip, if you are annoyed with
"CFURLCopyResourcePropertyForKey failed because it was passed this URL which has no scheme:" error messages in the terminal while running gitk.
Just add an alias into your .bash_profile:
alias gitk='gitk 2>/dev/null'


Monday, December 03, 2012

Code by Brian

My friend Brian started his own Android blog:

Code by Brian

Lots of useful stuff there and there is more to come.

Enjoy!

Sunday, December 02, 2012

Great article on Android UI performance by Romain

Stumbled upon this great article on Android UI performance problems detection tools, tips&tricks by Romain Guy on Google+:

http://www.curious-creature.org/docs/android-performance-case-study-1.html

Enjoy!

Friday, October 19, 2012

Mandiant on Android

I went to MIRcon 2012 conference this week and one of speakers was a guy from our company who does some R&D for Android at our New York office.
I found his blog very interesting and just wanted to share here:
http://thecobraden.blogspot.com/

Enjoy! :)

Thursday, May 10, 2012

Mac OS X tar util adds files with "._"


So, if you got surprised after uncomressing the tar.gz file that was created on Mac OS X and finding a bunch of extra files starting with "._" for every file and directory, here is a solution for you.
To avoid these extra files to be added into tar.gz on Mac OS X, define the environment variable:
export COPYFILE_DISABLE=true

Friday, March 30, 2012

javascript web development

Just wanted to share a few useful libraries if you plan to do a pure javascript web development:

* jQuery http://jquery.com/ - who doesn't know it, right ?

* Backbone.js http://documentcloud.github.com/backbone/ - a useful and light MVC framework, that effortlessly works with JSON server-side APIs

* RequireJS http://requirejs.org/ - the framework that provides bunch of useful functionality, such as automatic namespacing for the modules, javascript minification, pluggins support etc. One of the useful plug-ins is I18N that provides a good support for localization.

* Dust  http://akdubya.github.com/dustjs/ - fast and light templating engine.

Enjoy!

MongoDB: copy collections


Recently I got involved in the node.js type of project, with MongoDB back-end. Last time I played with MongoDB was more than a year ago, so I'm pretty much refreshing my memory at this point.

Here is,  for example how to copy the data from one collection to another:

db.srcCollection.find().forEach( function(c){db.destCollection.insert(c)} )


Thursday, March 22, 2012

Android: Updated SDK Tools and ADT revision 17

Google released the new update for Android SDK tools and ADT 17. Lots of yummy goodies inside.

I'm particularly excited about the new x86 emulator image running in virtualization mode (means faster emulator), that what I actually needed to test some of my native libs on x86 architecture.

For more details go to this link:
http://android-developers.blogspot.com/2012/03/updated-sdk-tools-and-adt-revision-17.html

At the end just wanted to add: I'm very impressed how well Google executes on it's Android initiative.

Wednesday, March 21, 2012

MacPorts: p5.12-term-readkey compilation failed

Just got the p5.12-term-readkey compilation failed error when I tried to upgrade outdated ports.

Here is the link to the ticket for more details:
https://trac.macports.org/ticket/33675

The solution:

$ sudo port -n upgrade --force perl5.12
$ sudo port clean p5.12-term-readkey

After that just continue upgrading the ports.

Tuesday, March 20, 2012

Objective-C "abstract" base class

Once upon a time I needed to port some Java code from Android to Objective-C iOS.

Just wanted to share one useful tip on how to express the abstract class in Objective-C.

Basically in the "abstract" base class the "abstract" methods should be implemented like this, for example:


- (int) myAbstractMethod {
    [self doesNotRecognizeSelector:_cmd];    
    return 0;
}

Then the method should be implemented as needed in the concrete child class.

Thursday, March 08, 2012

iOS device: EXC_BAD_ACCESS error with EXC_ARM_DA_ALIGN code

I spent a day hunting down one nasty bug in my code.
This code worked fine on Android ARM7 build, iPhone simulator (i386) build,
but started to crash once I run it on iPhone 4 device.

The code was implementing simple wrappers for the mutex, the event and the thread API.

For example the mutex handle looked something like this:

typedef struct _MUTEX_HANDLE {
    .........
    pthread_mutex_t mutex;
} MUTEX_HANDLE;

Then the event and thread structures where built upon this.

The problem only surfaced on iOS device, with error EXC_BAD_ACCESS and the code EXC_ARM_DA_ALIGN. I checked and double checked all the structures in memory their alignment etc., and still could not see anything wrong.  I searched online and got distracted with many articles reporting the similar type of problem and suggesting memcpy as a solution in order to "fix" this alignment issue.

The definitions of the pthread handles though was kind of curious:
struct _opaque_pthread_mutex_t { long __sig; char __opaque[__PTHREAD_MUTEX_SIZE__]; };
in addition to the signal handle there was an array.

Eventually I narrowed this down to the simple assignment by value where I just initialized 
pthread_mutex_t variable and assigned it by value to my structure member.

static int createMutex(MUTEX_HANDLE **pHandle) {
    pthread_mutex_t mtx;
    int err = initMutex(&mtx);
    if (!err) { 
        MUTEX_HANDLE *ph = malloc(sizeof(MUTEX_HANDLE));
        if (ph) {
           ph->mutex = mtx; //the problem is here, never do this!!! 

The pthread_mutex_t type is very simple structure on Android with one int member, so I kind of assumed that assigning pthread_mutex_t by value would not incur that much overhead or side effects and just did what I did above. So, this was not the best decision on my part.

The fix was to eliminate the temporary pthread_mutex_t variable on a stack and use the mutex member of the MUTEX_HANDLE structure directly: 

static int createMutex(MUTEX_HANDLE **pHandle) {
    MUTEX_HANDLE *ph = malloc(sizeof(MUTEX_HANDLE));
    if (ph) {
        int err = initMutex(&ph->mutex);

So, the EXC_ARM_DA_ALIGN error was just a big distraction that had me wasting quite a bit of time looking in the wrong direction. 


iOS 5.1 and Xcode 4.3.1 upgrade

I got the iOS 5.1 upgrade for my iPhone yesterday.
Then the Xcode needed to be upgraded to 4.3.1 in order to work with my phone with iOS 5.1.
Then cpp compiler link got screwed up again.
In the previous post I mentioned that you can fix with creating the new link:
sudo ln -s llvm-cpp-4.2 cpp


The old directory /Developer is gone now and the new one where you have to create the link is:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/

Enjoy!

Tuesday, March 06, 2012

Upgraded to Xcode 4.3, got missing cpp

Xcode upgrade to 4.3 had bitten me again, it removed the workaround for cpp compiler that I had to put in awhile back.

In this case I was building libcurl and got this error:
./configure: line 2062: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp: No such file or directory

sure enough the workaround as I posted before (Native libraries porting to iOS) is to create the missing symbolic link in the /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin directory:
ln -s llvm-cpp-4.2 cpp

Friday, March 02, 2012

XCode 4.3 and Mac ports

Just upgraded to XCode 4.3 and Mac ports started to give me this warning, when for example I tried to upgrade:

$ sudo port upgrade outdated
Warning: xcodebuild exists but failed to execute
Here is some help on this: https://trac.macports.org/ticket/33398

In order to fix this problem just  execute:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

Mac OS X hidden files in Finder app


Just wanted to share a couple of functions from my .bash_profile that allow to show or hide the hidden files and directories in Finder app on Mac OS X.

function showHidden {
defaults write com.apple.finder AppleShowAllFiles TRUE;
killall Finder;
}

function hideHidden {
defaults write com.apple.finder AppleShowAllFiles FALSE;
killall Finder;
}


Enjoy!

Tuesday, February 28, 2012

Mac OS X tips

Here is few tips for Mac OS X that I use quite often:

$ nm -A {file name} - to get list of symbols defined in the dynamic library.


$ otool -L {file name} - to get the list of shared libraries used by the dynamic library or executable.


$ lipo -info {file name} - to get the information on what CPU architectures are supported by the library or executable.


$ lsof -i -P | grep -i "listen" - to get the list of open ports with processes names that your machine is listening to.

$ man -k dtrace - lists lots of useful dtrace tools available, that allow to trace for example IO activity, processes, and many more

Monday, February 27, 2012

iOS ARC first impression

I started to use iOS ARC (automatic reference counting) feature on one of the brand new projects recently. It feels a bit weird leaving the dangling pointers around and takes few hours to get used to it.
Few open source projects I'm using actually followed the precedent and had the latest code already compatible with ARC. The rest of the non-ARC code is not that difficult to mix with existing project just have to use the compile flag for the files that is not ARC compliant: -fno-objc-arc

Overall it seems like the developers' job got a bit easier, leaving up to compiler to track the memory allocations and releases.
Feel free to post your thoughts on ARC and maybe you know some problems that I might get into down that path.
Thanks!

Saturday, February 11, 2012

Building MacVim on Mac OS X

Here are some instructions:
https://github.com/b4winckler/macvim/wiki/Building

The problem that I stumbled upon was the errors with libicon:
Undefined symbols for architecture x86_64:"_iconv", referenced from: ........

The libicon on the system is not compiled for 64bit by default.
To fix this you need to get the latest libiconv-1.14:
http://www.gnu.org/software/libiconv/#downloading

Configure it with:
CFLAGS='-arch i386 -arch x86_64' CCFLAGS='-arch i386 -arch x86_64' CXXFLAGS='-arch i386 -arch x86_64' ./configure
then >  make && make install

After that you can get the MacVim source code and build it fine, got 7.3.401 now.

Latest Vim for Mac OS X

The 7.3 version on Vim that comes with Mac OS X is getting old. It doesn't support some of the latest features and you would not be able to use some of the interpeters like ruby that is not supported out of the box.
One way to improve this is to install MacVim, another one is to recompile Vim from source code configuring some of the missing features. Here is how I configured it for myself for example:

* Get source code:
> hg clone https://vim.googlecode.com/hg/ vim

* Compile & Install:
> cd vim
> ./configure --enable-luainterp --enable-perlinterp --enable-pythoninterp --enable-tclinterp --enable-rubyinterp --enable-cscope
> make -j4
> make install

By default everything will be installed user /usr/local, so make sure that /user/local/bin is specified before /usr/bin in your PATH environment variable, or use a different prefix for ./configure  that already specified before /usr/bin path for example --prefix=/opt/local.

After these steps I got Vim 7.3.434 on my machine.