How to set proxy for Ubuntu Server 11.10

I spent lot of time figuring out how to set proxy on Ubuntu Server from command line. There are multiple ways mentioned on internet. Some works and some dont. Here’s what works and what dont. Hope this is useful.

What works: This worked first time :-) .

Create the file /etc/apt/apt.conf and put this line with your proxy settings : (By default I found that this file does not exist. so you need to create this).

Acquire::http::Proxy “http://login:password@yourproxyaddress:port“;

example:  Acquire::http::Proxy “http://bob:123bob@bobproxy:8070“;

What does not work: For me this method even after trying multiple times did not work.

Edit  your /etc/bash.bashrc file as root.

Put these line at the end of your /etc/bash.bashrc file :

export http_proxy=http://username:password@proxyserver.net:port/
export ftp_proxy=http://username:password@proxyserver.netport/

Posted in Open Source | Leave a comment

The Hunger Games Books Trilogy Review – Book 1

On my last weekend I finished reading all 3 books of “The Hunger Games” Trilogy practically in one sitting (technically with one 6 hour sleep break). All 3 books were so riveting that I just could not drop it.

I started with the book “The Hunger Games”.  Here’s review of it in my words:

This book engages you from the beginning and takes you into the life of hardship for Katniss Everdeen in “District 12″ and few moments of happiness in life when she is with her sister Prim, or hunting outside the District 12 boundaries with Jake or selling hunt at black market of “The Hob”. Books gives very engaging view of Katniss life and you immediately gets immersed in that. Then life takes turn for Katniss when Prim is selected for “The Hunger Games” organized by evil lords of “The Capitol”. These games are evil, where 24 contestants fight to death till 1 remains. Katniss could not bear Prim going there so she decides to volunteers. Katniss’s life changes, she sees “The Capitol” for the first time and how people there have all the luxries as opposed to hardships faced by people of “District 12″. She also starts to getting know Peeta, who secretly loves her and other member of her team who prepares her for the deadly games. Then she participates in the games and meets some deadly enemies and find some surprising friends, sees lot of death, discovers her care for Peeta and in the end with her wit comes winner with both Peeta and her alive. Capitol sees her manouvers as challenge to their authority but she is free atleast for the time being.

Pros:

  • Overall the book grasps you and you cannot keep it down till you have read it cover to cover.
  • Excellent narrative, you can see the district, characters and games in your head.
  • Novel story line
  • Not a all goody good novel where all good people are alive in the end. Lot of good people die.

Cons:

  • Apart from very engaging narrative people will notice that it’s all first hand from the eyes of Katniss. No other view point is ever presented. I did not like that, it’s engaging to some degree but when questions build and there is no real answer it’s a bit of disappointment. This is not very apparent in first book of the Trilogy but is very much there in 2nd and 3rd.

 In case you did not know here are the books of hunger games Trilogy:

  1. The Hunger Games
  2. Catching Fire
  3. Mockingjay
Posted in Life | Leave a comment

Millenial Media XNA Ad SDK for Windows Phone 7 Review

I tried using Millenial Media XNA Ad SDK for Windows Phone 7 few days back and ran into so many issues that I decided to blog for others to be able to quickly resolve them. I was able to resolve most of the issues except one big thorny issues which is still a blocker for using this SDK. I have sent lot of mails to Millenial Media supprot team but got no response.

Issues with Millenial Media XNA Ad SDK: (Version # 1.0.0.0. Release Date 2/08/11)

  • Ads get delivered for thier test app id but not for app id you get from thier portal:
    • Issue#1: By default they have different XML return  string for regular App id than for test app id. You will need to send a mail to thier technical staff for getting it fixed on thier back end.
    • How to debug: You will see exception in debug log: something like this:
      • [8/16/2011_2:49:41 PM] Calling for ad: http://ads.mp.mydas.mobi/getAd.php5?sdkapid=52813&mmisdk=0.6.1-12.08.10.xna&auid=dpw3uZPtKq181LFG+wO+vzqzpuo=&ua=Mozilla/4.0 (compatible; MSIE 7.0; Windows Phone OS 7.0; Trident/3.1; IEMobile/7.0;Microsoft;XDeviceEmulator)&adtype=MMBannerAdBottom&fw=0.0.0.0&hw=0.0.0.0&env=Microsoft Windows CE 7.10.7720&cachebuster=634491029812030000
        [8/16/2011_2:49:41 PM] Fetching ad
        [8/16/2011_2:49:41 PM] Response Length: 439
        A first chance exception of type ‘System.ArgumentNullException’ occurred in System.dll
        System.ArgumentNullException: Value can not be null.
        Parameter name: uriString
        at System.Uri..ctor(String uriString)
        at WP7XNASDK.MMAdView.XMLRespCallback(IAsyncResult asynchronousResult)
        at System.Net.Browser.ClientHttpWebRequest.<>c_DisplayClassa.<InvokeGetResponseCallback>b_8(Object state2)
        at System.Threading.ThreadPool.WorkItem.doWork(Object o)
        at System.Threading.Timer.ring()
    • Issue#2: By default Millenial Media serves 2 types of Ad Urls:
      • Url Type#1 : http://images.millennialmedia.com/4189/177243.gif
        • For this URL Type ads are displayed fine.
      • Url Type#2: http://ad.mo.doubleclick.net/dartproxy/dfa.mobile.handler?k=N4359.millennialmediaOX3851/B5091231.35;ord=[:_jv_orut:]
        • For this URL Type Windows Phone 7 networking APIs are not able to download the content as a result these ads cannot be displayed. Technically this is not Millenial Media issue. (I have tried raising the issue at Windows Phone 7 support forum with no resolution.) but to me this shows Millenial Media has not even tested their Windows Phone 7 SDK for thier Ad URLs. This is very disappointing to me. They could have easily avoided the issue by using other URL Mechanism. I have raised this issue with thier support and have not got any answer from them in over a week (though my earlier issue was resolved in a day).
      • How to debug this: You will see an ad XML of type and exception of type that Length of response is 0 in debug logs.<?xml version=”1.0″ encoding=”UTF-8″?>

        -<ad><bodyType/><clickUrl>http://bank37.mi.clicks.mp.mydas.mobi/handleClick.php5?apid=22280&auid=mmid_b360181f754f0364dbd02ab37b69be4afb_0131d46284b3&uip=131.107.0.109&mmid=6595&osid=37&urid=f6fc0c54d118f1d8fb09e3d50f0a1433&ri=37&acid=204204&mtpid=8753</clickUrl>-<image><url>http://ad.mo.doubleclick.net/dartproxy/dfa.mobile.handler?k=N4359.millennialmediaOX3851/B5091231.35;ord=[:_jv_orut:]</url><height>53</height><width>320</width><altText/></image><text/></ad>

 

Posted in WindowsPhone | 2 Comments

Ad Frameworks and Networks for Windows Phone 7

Following are the popular ad networks for Windows Phone 7 as of today and thier Pros and Cons. Other networks are also coming up, I will update this page if I find more interesting networks.

Ad Network Silverlight/XNA/Both Pros Cons Verdict
Microsoft PubCenter Silverlight + XNA 1)      Pay based on impressions.2)      Highest eCPM compared to other networks.

3)      Stable, Well supported, easy to integrate SDK.

4)      Good portal to let you see current stats with near real time data.

5)      Timely monthly payment.

1)      Serves ads only in US.2)      Does not show fill rate related statistics. Best if your app is primarily based in US. If not, then you will need to use this in combination with other networks.
AdMob Silverlight only 1)      World wide support.2)      Better eCPM than other ad networks.

3)      Well supported SDK

4)      Good portal to let you see current stats with real time data.

5)      Shows fill rate related stats.

1)      eCPM is not as great as Microsoft Pubcenter.2)      Works only on Silverlight and not XNA. Use this in conjunction with Microsoft Pubcenter if you have Silverlight app.
Millennial Media Silverlight + XNA 1)      World wide ad network.2)      Claims to support XNA

3)      Good portal with real time data.

4)      Shows fill rate related stats.

5)      Payment after 2 months.

1)      I tried XNA SDK and it does not work. period. Even their technical staff is not able to solve the issue.2)      You can make XNA SDK work partially  with lot of work. Look at my other post. You can try to integrate this as last ditch effort for your XNA App, but looks more hassle than actual work.
Smaato Silverlight + XNA 1)      World wide ad network. 

 

1)      Non realtime data on portal.2)      SDK for XNA did not work.

3)      Have heard about poor eCPM on this network.

Not sure if this can even be used for WP7 in current state.
AdDuplex XNA + Silverlight 1)      Supports world wide network 1)      This is an ad exchange network rather than traditional pay for ad network. Good to promote your paid apps.
Posted in WindowsPhone | Leave a comment

Analytics solutions for WP7 Apps

WP7 has started becoming popular in developer community. One of the big gaps for WP7 Development was lack of good (& free) analytics platforms.

Here’s a list of various analytics platfrom existing for WP7:

Platform Pros Cons
PreEmptive Solutions 1)      Free

2)      With bit of work you can track most of your data.

3)      Exposes raw data feed to do your own xl based analytics.

1) Hard to use. Rather than API calls, it’s .Net reflection based.

2)      Bit limited in what all you can track.

3)      Not realtime: There is huge lag between data ingress and availability for analysis.

Mitks 1)      Realtime Analytics.

2)      Got Apps (WP7, Ipxx, Android) to see analytics on go.

3)      Gives loyalty report, app usage, devices usage.

http://www.1800pocketpc.com/2011/02/23/mtiks-free-real-time-analytics-for-windows-phone-7.html

1)      Advanced features like exception tracking are part of premium version.
Localytics 1)      Free for individual developers.

2)      Can track upto 50 apps for free.

3)      Can track individual feature usage

4)      Got great analytics features for new vs returning user analysis, loyal user analysis.

1)      No exception tracking.

2)      Some advanced reporting is available only in premium features.

Eqatec 1)      Most advanced set of features

2)      Realtime analytics

3)      Ability to track usage.

4)      Ability to track individual features.

5)      Ability to track values within features.

6)      Ability to track exceptions.

7)      Got free trial for upto ~3 months.

1)      Free version is limited to 1 app.

Verdict:

1) My favorite one so far is Eqatec. It’s very easy to integrate and very easy to change the id if you change the account. It’s 3 month free trial gives me ample time  (& anyways a new update is always going to come out in 3months ;-) )

2) I didnt like Premptive. I tried that and first of all it’s data has huge lag (in one case more than 2 weeks and usually of 3-4 days) making it not so useful. 2nd it’s presentation of information is very poor. I could not make much deductions using it.

3) Mtiks looks promising and I have heard people using.

4) Localytics looks limited in its free offerings.

Posted in WindowsPhone | Leave a comment

How to start learning Android App Development

Often people ask where to start learning Android App Development.

I have found that even though most of the material is available online it’s probably more efficient to buy/borrow/steal(not that I recommend it :-) ) a book and use that to start learning Android.

Almost all the details available in books will be available online, however books have inherent advantage of presenting a material in coherent and step-by-step manner. This aspect of books is immensely useful for someone just starting up.

However, not all books are made equal. Below are my recommendations on books for Android. These books will help you if you become proficient in Android:

  1. Pragmatic Hello Android 3rd Edition
    1. Pros:
      1. This book covers the basic and does not presume anything. Not even that you are proficient in Java
      2. It starts from the basics of installations to developing some useful Android Apps.
      3. Even though it does not cover lot of advanced stuff, it is very useful for people who are starting up with Android.
    2. Cons:
      1. Does not cover lot of advanced concepts which you will need to know to develop powerful programs.
      2. If you know the basics on Android, you know everything in the book.
    3. Verdict:Very good for people starting up with no or little prior knowledge of Android
  2. Beginning Android 3
    1. Pros:
      1. Covers lot of details about the Android system.
      2. Gives info about (intermediate level) advanced and useful concepts.
      3. If you already know the basics, you deal with stuff you would want to know about rather than dealing with basics.
    2. Cons:
      1. Presupposes you know Java.
      2. Does not go into basics of starting up with Android. (Update: Looks like Beginning Android 3 now includes basics of getting started with Android. So this looks good).
    3. Verdict: Would be a good 2nd book to build up on your existing Android knowledge.

I will keep adding up here as I find more. Suggestions are always welcome.

Posted in Android | Leave a comment

Android: Layout_Weight not taking effect or not being proportional to what you set

Problem: While developing for Android I found out that lot of times Layout Weight I was setting was not taking effect properly. Some times it did not take effect at all and at other times it was not proportional to what I set.

Solution: Solution here lies in realizing that there is some internal dependencies between layout_weight and layout_hieght and width properties. If all of them are set then sometimes results become inpredictable. As a result it’s a good practise to set “width” and “height” of the element to zero if you want actual height and width to be control via wieght.

Surprisingly for me this issue was most apparent when I was using a mix of ImageView and Textview in a linear layout. when I had linearlayout of all textviews or all imageviews it was working intutively.

For ex, consider this layout where I have 3 images and 1 text view in vertical linear view. Now my aim is very simple: to distribute them equally (vertical wise) on the screen. So I set equal weigth to all of them and set all the height as “fill_parent” assuming weight will take care of height.

<LinearLayout android:weightSum=”1″ android:id=”@+id/linearLayout1″ android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:layout_above=”@+id/next_button” android:layout_alignParentRight=”true” android:layout_alignParentLeft=”true”>

<ImageView android:layout_weight=”.25″ android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:src=”@drawable/apple” android:id=”@+id/imageView3″ android:scaleType=”fitCenter”></ImageView>

<ImageView android:layout_weight=”.25″ android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:src=”@drawable/apple” android:id=”@+id/imageView3″ android:scaleType=”fitCenter”></ImageView>

<ImageView android:layout_weight=”.25″ android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:src=”@drawable/apple” android:id=”@+id/imageView3″ android:scaleType=”fitCenter”></ImageView>

<TextView android:layout_weight=”.25″ android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:text=”A” android:textSize=”70sp” android:typeface=”monospace” android:textColor=”@android:color/black” android:clickable=”true” android:onClick=”onClick” android:includeFontPadding=”false” android:gravity=”center”></TextView>

</LinearLayout>

In the above example the proportion never came out right. Till I changed the code to use height=”0dp” for all elements like below. Without height marked as 0dp, the weight element was not able to do its work.

<LinearLayout android:weightSum=”1″ android:id=”@+id/linearLayout1″ android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:layout_above=”@+id/next_button” android:layout_alignParentRight=”true” android:layout_alignParentLeft=”true”>

<ImageView android:layout_weight=”.25″ android:layout_width=”fill_parent” android:layout_height=”0dp” android:src=”@drawable/apple” android:id=”@+id/imageView3″ android:scaleType=”fitCenter”></ImageView>

<ImageView android:layout_weight=”.25″ android:layout_width=”fill_parent” android:layout_height=”0dp” android:src=”@drawable/apple” android:id=”@+id/imageView3″ android:scaleType=”fitCenter”></ImageView>

<ImageView android:layout_weight=”.25″ android:layout_width=”fill_parent” android:layout_height=”0dp” android:src=”@drawable/apple” android:id=”@+id/imageView3″ android:scaleType=”fitCenter”></ImageView>

<TextView android:layout_weight=”.25″ android:layout_width=”fill_parent” android:layout_height=”0dp” android:text=”A” android:textSize=”70sp” android:typeface=”monospace” android:textColor=”@android:color/black” android:clickable=”true” android:onClick=”onClick” android:includeFontPadding=”false” android:gravity=”center”></TextView>

</LinearLayout>

 

Conclusion: When using “Layout_Weight” element to distribute a screen then set “layout_width” or “layout_height” appropriately to “0dp”. Otherwise you may see weird results.

Posted in Android | Leave a comment

Error 1047: An update cannot support fewer languages than the previous app instance supported.

On Windows Phone these days while submitting an update on Windows Phone market place you can face errors like:

  1. Error 2003: The [NeutralResourceLanguage] attribute is missing on the entry assembly.
  2. Error 1047: An update cannot support fewer languages than the previous app instance supported.
  3. Error 1048: A language supported in this XAP conflicts with a language that is already supported by another app instance for this app.

These errors started appearing recently because of update by Windows Phone market place team where they are making changes in preperation for Windows Phone 7.1 update.

This msdn posts gives very good details of the issues and how to solve them:http://forums.create.msdn.com/forums/t/87638.aspx

However, almost all the points miss on one important aspect. Most of them assume that you have moved to yet in Beta Developer tools for Windows Phone 7.1 Beta2. Because SDK Tools in that version will take care of these issues for you. However if you have not yet moved to Beta2 then few things to note:

1) If you are submitting a new app you will have to manuall add a line in AssemblyInfo.cs file to specificy default language. Something like: Since it was not required for old apps it creates confusion.

[assembly: NeutralResourcesLanguageAttribute("en-US")]

2) If you are submitting an update to your exsiting app, you will find that even after adding the above like you will get error like:

1047: An update cannot support fewer languages than the previous app instance supported.

 To solve that you need to change the language to “en” from “en-US”. Since earlier update did not have this attribute it apparently defaulted to “en”.

Hope this helps you!

 

 

Posted in WindowsPhone | Leave a comment

Android Media Player Exceptions: Common Problem and Solutions

Problem: When using Android Media Player you get exception:

  1. java.io.IOException: Prepare failed.: status=0x1
  2. Java.io.exception: setDataSource error 0x800000

Common Solutions:

  1. Lot of people have said this is many times due to bad or corrupted Mp3 ,OGG or other file.
  2. Another solution is MediaPlayer.setDataSource has 3 overloaded variants. but the one which works is the one which takes 3 parameters, FileDescriptor, start Offset and length. If you dont give all 3 you face this issue. A newbie is very likely to hit this.

 

Common ways to debug this:

  1. If you are using MediaPlayer.Create(XXX) variant then most likely the issue is bad corrputed file.
  2. Most people face issue#2 when they try to use setDataSource vriant. Keep in mind to use the right one.
  3. To debug issue whether MP3 is corrupted or not : try copying the MP3 to raw directory and then use MediaPlayer.Create(resource id) variant. If that fails then most probably issue is with the file. If that works then that confirms the quality of your file and you need to look at your code.

Hope this helps. I spent lot of time struggling with MediaPlayer issues. Let me know if you face any and I will try to help you as much as I can.

 

Posted in Android | Leave a comment

On Android Ecplise IDE: libpng error: Not a PNG file

Problem:I recently faced an issue where when I added my png file to an Android project it complained that it’s not a PNG file.

Error I faced:

[2011-07-24 19:54:00 - xxxx] libpng error: Not a PNG file
[2011-07-24 19:54:00 - xxxx] ERROR: Failure processing PNG image C:\Users\pawana\workspace\xxxx\res\drawable-nodpi\background.png
[2011-07-24 19:54:00 - xxxx] C:\Users\pawana\workspace\xxxx\res\layout\main.xml:7: error: Error: No resource found that matches the given name (at ‘background’ with value ‘@drawable/background’).

Environment: I was using “windows 7″ for development and that file was opening file as a PNG File on Windows 7. I was puzzled what was happening.

Background: I tried searching the web if someone else faced this issue and what as the solution. There were no good answers. I had verified my PNG was 24 bit. Android does support 24-bit and 32-bit. After lot of research it occured to me that maybe Android does not like the PNG format of “Adobe Photoshop”, too which I used to create the PNG.

Solution: Final solution was to open the png file in MS Paint and re save it as png file. Once I did that Eclipse was able to use that file in Android project. I looked at what it changed, it convered the PNG to 32-bit format. Since Android supports both 24-bit and 32-bit PNGs, it makes me think there is something with “Adobe Phtoshop” generated PNGs which Android does not like.

If someone knows more, feel free to comment on the post.

Posted in Android | Leave a comment