<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Blog is Tech &#187; Android</title>
	<atom:link href="http://www.techblogistech.com/category/mobile/android-mobile/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techblogistech.com</link>
	<description>Exploring technology in the modern world</description>
	<lastBuildDate>Sat, 04 May 2013 14:10:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How to Install Specific Android SDK Packages from Command Line (headless server)</title>
		<link>http://www.techblogistech.com/2012/02/install-android-sdk-packages-command-line/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=install-android-sdk-packages-command-line</link>
		<comments>http://www.techblogistech.com/2012/02/install-android-sdk-packages-command-line/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 21:00:32 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[google+]]></category>
		<category><![CDATA[headless]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[specific]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=765</guid>
		<description><![CDATA[Installing the Android SDK on a headless server doesn&#8217;t seem to be very well documented. I recently needed to do &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2012/02/install-android-sdk-packages-command-line/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" rel="shadowbox[sbpost-765];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" alt="Droid" title="Droid" width="77" height="90" class="lazy alignright size-full wp-image-709" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" alt="Droid" title="Droid" width="77" height="90" class="alignright size-full wp-image-709" /></noscript></a>Installing the Android SDK on a headless server doesn&#8217;t seem to be very well documented.  I recently needed to do this to get the SDK installed on a TeamCity build agent to automate Android builds and tests.</p>
<p>Below are some simple instructions to help you along the way.  I&#8217;m using a Mac, so you may need to use slightly different commands if you&#8217;re using Linux.</p>
<p><span id="more-765"></span></p>
<h2>Step 1: Download the Android SDK onto the box</h2>
<p>You&#8217;ll want to grab the latest SDK from <a href="http://developer.android.com/sdk/index.html" title="Android Developers: Android SDK download" target="_blank">Google&#8217;s Android SDK page</a>.  As of this post, the latest version for Mac is <a href="http://dl.google.com/android/android-sdk_r16-macosx.zip" title="Android SDK: R16 Mac OS X" target="_blank">android-sdk_r16-macosx.zip</a>.  I used this command to download this on my Mac:</p>
<pre class="bigbash">$ curl -C - -O http://dl.google.com/android/android-sdk_r16-macosx.zip</pre>
<h2>Step 2: Unzip the SDK</h2>
<p>I decided to put the SDK in my <strong>/Applications</strong> directory.  You can put it wherever you want, but if you want to follow my lead you can use the following commands to get it into the /Applications dir:</p>
<pre class="bigbash">$ mv android-sdk_r16-macosx.zip /Applications
$ cd /Applications
$ unzip android-sdk_r16-macosx.zip
</pre>
<h2>Step 3: Determine what API levels, tools, and documentation you want to install</h2>
<p>You now have a base SDK installed, but you still need to download the corresponding Android APIs for whichever Android version you&#8217;re developing for.  In order to know what you need to install, you&#8217;ll want to list the available APIs, tools, and docs.  We can use the <strong>android</strong> tool to do this and the <strong>&#8211;no-ui</strong> flag to alert the tool that we&#8217;re on the command line.  Here is how to get a list of what&#8217;s available:</p>
<pre class="bigbash">$ cd /Applications/android-sdk-macosx
$ tools/android list sdk --no-ui
Refresh Sources:
  Fetching https://dl-ssl.google.com/android/repository/addons_list-1.xml
  Validate XML
  Parse XML

  ...snip...

Packages available for installation or update: 61
   1- Documentation for Android SDK, API 15, revision 1
   2- SDK Platform Android 4.0.3, API 15, revision 2
   3- SDK Platform Android 4.0, API 14, revision 3
   4- SDK Platform Android 3.2, API 13, revision 1
   5- SDK Platform Android 3.1, API 12, revision 3
   6- SDK Platform Android 3.0, API 11, revision 2
   7- SDK Platform Android 2.3.3, API 10, revision 2
   8- SDK Platform Android 2.2, API 8, revision 3
   9- SDK Platform Android 2.1, API 7, revision 3
  10- SDK Platform Android 1.6, API 4, revision 3
  11- SDK Platform Android 1.5, API 3, revision 4

  ...snip...

  56- Android Support package, revision 6
  57- Google Admob Ads Sdk package, revision 4
  58- Google Analytics Sdk package, revision 2
  59- Google Market Billing package, revision 1
  60- Google Market Licensing package, revision 1
  61- Google Webdriver package, revision 2
</pre>
<h2>Step 4: Install your packages</h2>
<p>Ok, so you have a list of the APIs and tools.  See which ones you want to install and find their corresponding number.  If you want to install <strong>API 15</strong> and the <strong>Android Support package</strong>, you&#8217;ll want number <strong>2</strong> and <strong>56</strong>.  We can use the <strong>android</strong> tool again and the <strong>&#8211;filter</strong> flag to alert it that we only want to install package 2 and 56:</p>
<pre class="bigbash">$ tools/android update sdk --filter 2,56 --no-ui</pre>
<h2>You&#8217;re done!</h2>
<p>Happy hacking Android devs!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2012/02/install-android-sdk-packages-command-line/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Fix EXC_BAD_ACCESS (SIGSEGV) in HelloAndroid</title>
		<link>http://www.techblogistech.com/2011/11/how-to-fix-exc_bad_access-sigsegv-in-helloandroid/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-fix-exc_bad_access-sigsegv-in-helloandroid</link>
		<comments>http://www.techblogistech.com/2011/11/how-to-fix-exc_bad_access-sigsegv-in-helloandroid/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 17:39:50 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[avd]]></category>
		<category><![CDATA[exc_bad_access]]></category>
		<category><![CDATA[kern_invalid_access]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[sigsegv]]></category>
		<category><![CDATA[snapshots]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=716</guid>
		<description><![CDATA[When trying to build the Android Hello World tutorial in Eclipse I ran into an issue where the application would &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2011/11/how-to-fix-exc_bad_access-sigsegv-in-helloandroid/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" rel="shadowbox[sbpost-716];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" alt="Droid" title="Droid" width="77" height="90" class="lazy alignright size-full wp-image-709" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" alt="Droid" title="Droid" width="77" height="90" class="alignright size-full wp-image-709" /></noscript></a>When trying to build the <a href="http://developer.android.com/resources/tutorials/hello-world.html" title="Android Hello World tutorial" target="_blank">Android Hello World tutorial</a> in Eclipse I ran into an issue where the application would just crash when I tried to run it:</p>
<pre>[2010-05-04 01:53:46 - HelloAndroid] ------------------------------
[2010-05-04 01:53:46 - HelloAndroid] Android Launch!
[2010-05-04 01:53:46 - HelloAndroid] adb is running normally.
[2010-05-04 01:53:46 - HelloAndroid] Performing com.example.helloandroid.HelloAndroid activity launch
[2010-05-04 01:53:46 - HelloAndroid] Automatic Target Mode: launching new emulator with compatible AVD 'myAVD'
[2010-05-04 01:53:46 - HelloAndroid] Launching a new emulator with Virtual Device 'myAVD'
[2010-05-04 01:53:58 - HelloAndroid] New emulator found: emulator-5554
[2010-05-04 01:53:58 - HelloAndroid] Waiting for HOME ('android.process.acore') to be launched...
[2010-05-04 01:53:59 - Emulator] 2010-05-04 01:53:59.501 emulator[10398:903] Warning once: This application, or a library it uses, is using NSQuickDrawView, which has been deprecated. Apps should cease use of QuickDraw and move to Quartz.
[2010-05-04 01:54:23 - HelloAndroid] emulator-5554 disconnected! Cancelling 'com.example.helloandroid.HelloAndroid activity launch'!</pre>
<p>The crash report was identifying the problem as a segfault:</p>
<pre>Process:         emulator [10472]
Path:            /Applications/android-sdk-mac_86/tools/emulator
Identifier:      emulator
Version:         ??? (???)
Code Type:       X86 (Native)
Parent Process:  eclipse [10468]

Date/Time:       2010-05-04 02:25:41.153 -0500
OS Version:      Mac OS X 10.6.3 (10D573)
Report Version:  6

Interval Since Last Report:          2558914 sec
Crashes Since Last Report:           4
Per-App Crashes Since Last Report:   2
Anonymous UUID:                      C5F178C1-5290-4CA9-AD6E-E9C4F5582754

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x000000001fd2f000
Crashed Thread:  3</pre>
<h3>The explanation</h3>
<p>As best I could tell a snapshot of my AVD was saved while the previous version of HelloAndroid was running.  And so when I went to run the new version of HelloAndroid (after making some code changes) the new package was copied over and then the emulator was restored.  At this point it was in a corrupt state where the old version was still in memory but the new version existed in local storage.  This may or may not be <strong>exactly</strong> what was happening, but it appeared to be what was causing the app to crash.</p>
<h3>The fix</h3>
<p>For me, I simply turned snapshots off on my AVD.  To do that in Eclipse you can just follow this menu/button options:<br />
Window -> AVD Manager -> [select your avd] -> Click Edit -> Uncheck &#8220;Enabled&#8221; next to Snapshots</p>
<p>If this doesn&#8217;t work you can also delete the AVD and create a new one with the same settings but with snapshots disabled.</p>
<p>If you&#8217;re still running into trouble, check out <a href="http://stackoverflow.com/questions/2763395/issue-with-hello-android-tutorial" title="Issue with Hello Android Tutorial" target="_blank">this thread</a> over at StackOverflow.  It didn&#8217;t solve my problems, but your mileage may vary. <img src='http://www.techblogistech.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h4>Happy Android Coding!</h4>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2011/11/how-to-fix-exc_bad_access-sigsegv-in-helloandroid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Fix the Android NetworkOnMainThreadException</title>
		<link>http://www.techblogistech.com/2011/11/how-to-fix-the-android-networkonmainthreadexception/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-fix-the-android-networkonmainthreadexception</link>
		<comments>http://www.techblogistech.com/2011/11/how-to-fix-the-android-networkonmainthreadexception/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 17:08:01 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[async]]></category>
		<category><![CDATA[asynctask]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[handlers]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[networkonmainthreadexception]]></category>
		<category><![CDATA[threading]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=707</guid>
		<description><![CDATA[If you&#8217;re trying to communicate with a web service or scrape any data from the web in your Android application, &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2011/11/how-to-fix-the-android-networkonmainthreadexception/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" rel="shadowbox[sbpost-707];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" alt="Droid" title="Droid" width="77" height="90" class="lazy alignright size-full wp-image-709" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2011/11/droid.png" alt="Droid" title="Droid" width="77" height="90" class="alignright size-full wp-image-709" /></noscript></a>If you&#8217;re trying to communicate with a web service or scrape any data from the web in your Android application, you might run into an exception like this:</p>
<pre>E/AndroidRuntime(673): java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.helloandroid/com.example.helloandroid.HelloAndroidActivity}: android.os.NetworkOnMainThreadException</pre>
<p>From Google&#8217;s documentation:</p>
<blockquote><p>
The exception that is thrown when an application attempts to perform a networking operation on its main thread.</p>
<p>This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it&#8217;s heavily discouraged.
</p></blockquote>
<h3>The fix</h3>
<p>The problem here is simply that you need to make your web service calls (or what-have-you) on a separate thread.  So, quite simply, you&#8217;ll need to look into how to do threading with Android.  Unfortunately this can be a bit of a pain because you need to make your service calls on a separate thread, but you need to update the UI on the main thread.  Normally this would require passing data between the threads, which involves handlers or other complexities.  Luckily the Android platform provides the Async Task to handle this, which alleviates some of this complexity and may help you avoid some clutter in your code.</p>
<h4>Useful documentation to migrate your network calls to threads (or Android&#8217;s Async Task)</h4>
<p><a href="http://developer.android.com/resources/articles/painless-threading.html" title="Painless Threading" target="_blank">Painless Threading (from the Android Developer docs)</a><br />
<a href="http://developer.android.com/reference/android/os/AsyncTask.html" title="Async Task" target="_blank">Async Task (from the Android Developer docs)</a><br />
<a href="http://www.vogella.de/articles/AndroidPerformance/article.html" title="Android Threads, Handlers and AsyncTask - Tutorial" target="_blank">Android Threads, Handlers and AsyncTask &#8211; Tutorial</a><br />
<a href="http://developer.android.com/guide/practices/design/responsiveness.html" title="Designing for Responsiveness" target="_blank">Designing for Responsiveness (from the Android Developer docs)</a></p>
<h4>Good luck!</h4>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2011/11/how-to-fix-the-android-networkonmainthreadexception/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
