Tuesday, May 15, 2012
gson error in android application while JSON parsing | type mismatch JSON error with gson
issue : It worked fine on all android phones (fyi.. tested on few Motorola,Samsung and HTC devices..) except the HTC Explorer(a good Value for money phone as a testing device even for personal usage).
btw, error was in JSON parsing (library).. and While I was trying to run,..YUCK! I was getting a "Force Close" with some type mismatch JSON based error!
Solution:
The "fix" of renaming the gson package with jarjar did the trick..
If anyone else has this problem, here's a quick solution; (fyi, we are using gson 1.6)
Steps - how-to fix it:
1) Download jarjar (http://code.google.com/p/jarjar/downloads/list)
2) Put jarjar-1.0.jar and gson-1.6.jar in the same folder
3) Create a new text file in this folder (rules.txt)
4) Write the following line in the textfile: rule com.google.gson.** com.google.myjson.@1
5) From the command line, open jarjar with the command "java -jar jarjar.jar process rules.txt gson-1.6.jar myjson-1.6.jar"
6) Replace the gson library in your project with myjson and update the imports
so what was the reason.. OOuch! many of the android devices (probably the HTC, as I observed) use GSON library for internal apps... this is what I know.. not sure :) ..
Droid guys! Stay tuned for more bugs..ah! solutions ;)
Saturday, April 14, 2012
Tuesday, March 6, 2012
Eclipse – Your project contains error(s), please fix them before running your application.
ACTUALLY there was no error in code; I tried project -> clean. TOUGH LUCK :(
I was pretty annoyed, because I was not able to run my app to test on my Android device.
After doing a lot of investigation:
I got that this is a little annoyance you’re going to get now and then. To fix it, just use the “Problems” window which is docked at the bottom by default, right click on the Error(s) listed and delete.
Try to run now. Yay! Its running now...
If still any issue, might be you need to run project - clean.
Hope this helps!
Tuesday, January 17, 2012
iPhone | Getting touch event in UIScrollView Or scrollable UITableView
Unable to get tap event in scrolling view or scrollable table view?
hmm... Really a bad situation.. by the way here is the solution :)
Put this in viewDidLoad method :
(YOUR_SCROLL_VIEW may be UIScrollView or scrollable UITableView)
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(singleTapGestureCaptured:)]; [YOUR_SCROLL_VIEW addGestureRecognizer:singleTap];
and you will get the touches with :
- (void)singleTapGestureCaptured:(UITapGestureRecognizer *)gesture {
CGPoint touchPoint=[gesture locationInView:YOUR_SCROLL_VIEW];
NSLog(@"Touch point coordinates are : %f - %f", touchPoint.x , touchPoint.y );
}
this worked for me, hope this helps to save your time!
Monday, November 28, 2011
iPhone | Convert UILabel to Circle
2) Import QuartzCore.h file to implementation file.
3) #define kRectArmLength 24.0 (Not necessary, as you can decide while initializing label with frame)
//Label will be a square (equal width & height)
UILabel *lblCircle = [[UILabel alloc] initWithFrame:CGRectMake(10,20, kRectArmLength, kRectArmLength)];
//set corner radius just half of the square arm length
lblCircle.layer.cornerRadius= kRectArmLength/2;
lblCircle.clipsToBounds=YES;
lblCircle.backgroundColor = [UIColor redColor];
[self.view adsSubview: lblCircle];
Wednesday, November 16, 2011
Phonegap | Whitelist rejection in phonegap compilation with Xcode
whitelist rejection in phonegap compilation
The solution is to Whitelist (allow) the host to be accessible via phonegap, to accomplish it
Add new row to External Host (Key value pair)
for value, put your host name : (SERVER.COM).
e.g.
1) ERROR whitelist rejection: url('http://localhost:XXXX/myproject/index')
Type: localhost in value column for for External Host
2) ERROR whitelist rejection: url('http://myserver.com/dashboard/mobilews.php?')
Type: myserver in value column for External Host
May be putting "*" , the asterisk as a value of the host that references an external URL , will do the trick. but not safe.
see my comments below for more info, as phonegap is cordova now!
Saturday, November 5, 2011
iPhone build error | Codesign failed with exit code 1| object file format invalid or unsuitable
Project timelines are always important, So I reverted back to Xcode 3.2.6
Everything went Okay. But when I tried to apply ( code signing) provisioning certificates to install application into iPhone, Build Failed with error;
Command /usr/bin/codesign failed with exit code 1
with description-
{*}.app object file format invalid or unsuitable
Then I moved to the solution library of developers (stack overflow), As most of the the developers do :)
After spending lot of hours, Saw this answer by emcmanus.
sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin
Tried first command, Blindly..
My terminal CLI answered : No such file or directory!
Then, I Explored /usr/bin folder, and observed yes! It was not there. (there is nothing to keep as back up , after renaming it. Symlinking is the ultimate goal )
I run "sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin"
to create symlink.
and YES! symlink did the trick...
Excellent... Hope this will do the trick for, who is in this trap :)