<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Android on bramp.net</title>
    <link>https://blog.bramp.net/</link>
    <description>Recent content in Android on bramp.net</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-GB</language>
    <lastBuildDate>Sat, 01 Aug 2015 12:24:59 -0700</lastBuildDate>
    <atom:link href="https://blog.bramp.net/tags/android/" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Decompile and Recompile Android APK</title>
      <link>https://blog.bramp.net/post/2015/08/01/decompile-and-recompile-android-apk/</link>
      <pubDate>Sat, 01 Aug 2015 12:24:59 -0700</pubDate>
      
      <guid>https://blog.bramp.net/post/2015/08/01/decompile-and-recompile-android-apk/</guid>
      <description><p>I had the need to take an existing <a href="https://en.wikipedia.org/wiki/Android_application_package">Android APK</a>, tweak it, and rebuild. This is not too difficult, but I did have to download the tools from a few different sites, and find a full list of instructions. Thus to make this easier, here is a quick recap of what&rsquo;s needed.</p>
<p>Download the following:</p>
<ul>
<li><a href="http://ibotpeaches.github.io/Apktool/">apktool</a> - tool for reverse engineering Android apk files. In this case can extract and rebuild.</li>
<li><a href="https://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html">keytool</a> - Java tool for creating keys/certs. Comes with the JDK.</li>
<li><a href="https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jarsigner.html">jarsigner</a> Java tool for signing JAR/APK files. Comes with the JDK.</li>
<li><a href="https://developer.android.com/tools/help/zipalign.html">zipalign</a> - archive alignment tool, that comes with the Android SDK.</li>
</ul>
<p>Some extras:</p>
<ul>
<li><a href="http://jd.benow.ca/">JD-GUI</a> - Java Decompiler</li>
<li><a href="https://github.com/pxb1988/dex2jar">dex2jar</a> - Converts Android dex files to class/jar files.</li>
</ul>
<h2 id="instructions">Instructions:</h2>
<p>We assume you are on a Linux or Mac, but this will work (with some tweaking) on Windows. Install a recent Java JDK, then the <a href="https://developer.android.com/sdk/installing/index.html?pkg=tools">Stand-alone Android SDK</a>, and finally <a href="http://ibotpeaches.github.io/Apktool/">apktool</a>.</p>
<p>Optionally setup some alias:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">alias</span> <span class="nv">apktool</span><span class="o">=</span><span class="s1">&#39;java -jar ~/bin/apktool_2.0.1.jar&#39;</span>
</span></span><span class="line"><span class="cl"><span class="nb">alias</span> <span class="nv">dex2jar</span><span class="o">=</span><span class="s1">&#39;~/bin/dex2jar-2.0/d2j-dex2jar.sh&#39;</span>
</span></span><span class="line"><span class="cl"><span class="nb">alias</span> jd-gui<span class="o">=</span><span class="s1">&#39;java -jar ~/bin/jd-gui-1.3.0.jar&#39;</span>
</span></span></code></pre></div><p>First, unpack the application.apk file. This will create a &ldquo;application&rdquo; directory with assets, resources, compiled code, etc.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">apktool d -r -s application.apk
</span></span></code></pre></div><p>Now poke around, and edit any of the files in the application directory. If you wish to decompile any java you can do the following:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Convert the Dex files into standard class files</span>
</span></span><span class="line"><span class="cl">dex2jar application/classes.dex
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Now use the JD (Java Decompiler) to inspect the source</span>
</span></span><span class="line"><span class="cl">jd-gui classes-dex2jar.jar
</span></span></code></pre></div><p>Once you have made your changes, you need to repack the APK. This will create a <code>my_application.apk</code> file:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">apktool b -f -d application
</span></span><span class="line"><span class="cl">mv application/dist/application.apk my_application.apk
</span></span></code></pre></div><p>The APK must be signed before it will run on a device. Create a key if you don&rsquo;t have an existing one. If prompted for a password, enter anything (but remember it).</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">keytool -genkey -v -keystore my-release-key.keystore -alias alias_name <span class="se">\
</span></span></span><span class="line"><span class="cl">                   -keyalg RSA -keysize <span class="m">2048</span> -validity <span class="m">10000</span>
</span></span></code></pre></div><p>Now sign the APK with the key:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Sign the apk</span>
</span></span><span class="line"><span class="cl">jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Verify apk</span>
</span></span><span class="line"><span class="cl">jarsigner -verify -verbose -certs my_application.apk
</span></span></code></pre></div><p>Finally, the apk must be aligned for optimal loading:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">zipalign -v <span class="m">4</span> my_application.apk my_application-aligned.apk
</span></span></code></pre></div><p>Voila, now you have a <code>my_application-aligned.apk</code> file, which you can side load onto your device.</p>
</description>
    </item>
    
    <item>
      <title>I have native IPv6</title>
      <link>https://blog.bramp.net/post/2012/06/26/i-have-native-ipv6/</link>
      <pubDate>Tue, 26 Jun 2012 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2012/06/26/i-have-native-ipv6/</guid>
      <description><p>I’m more excited than I should be, but today I noticed that Comcast has enabled IPv6 on my home internet connection. All my devices in the home have picked up one or more Internet routable IPv6 addresses. Here are a few screen shots:</p>
<p><figure><img src="/post/2012/06/26/i-have-native-ipv6/ifconfig-v6.png"><figcaption>
      <h4>IPv6 ifconfig</h4>
    </figcaption>
</figure>

<figure><img src="/post/2012/06/26/i-have-native-ipv6/google-v6.png"><figcaption>
      <h4>IPv6 Google!</h4>
    </figcaption>
</figure>

<figure><img src="/post/2012/06/26/i-have-native-ipv6/facebook-v6.png"><figcaption>
      <h4>IPv6 Facebook</h4>
    </figcaption>
</figure>

<figure><img src="/post/2012/06/26/i-have-native-ipv6/bramp-v6.png"><figcaption>
      <h4>IPv6 my website (thanks to Amazon AWS)</h4>
    </figcaption>
</figure>

<figure><img src="/post/2012/06/26/i-have-native-ipv6/android-v6.png"><figcaption>
      <h4>even my Android phone has IPv6!</h4>
    </figcaption>
</figure>
</p>
<p>So this is very cool, but this has identified a few issues. The most important of which, is that I had previously been using my NAT as a firewall, protecting all devices on the internal network. However, now they all have external IP addresses, they are effectively open to the Internet and un-firewalled. That’s not an issue for my Linux machines, but could be problematic for my girlfriend’s Windows laptop, and my various embedded devices (phones, tablets, and TVs).</p></description>
    </item>
    
    <item>
      <title>Avoid Bloat Freezer Free</title>
      <link>https://blog.bramp.net/post/2012/01/14/avoid-bloat-freezer-free/</link>
      <pubDate>Sat, 14 Jan 2012 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2012/01/14/avoid-bloat-freezer-free/</guid>
      <description><p>Over a month ago I install “Bloat Freezer Free”, a tool designed to kill of particular services running in the background, such as those installed by your phone manufactor. It seemed to be working fine, but in the last few days I’ve been getting a green star in my notification bar alerting me to “There is a update to the Android Market”. If I click it, it takes me to some spyware looking site to download a new market place. Then today I get an alert with the same green star saying “Badoo”. If it click that it links me via some porn advertiser and I end up at the Google Market for the Badoo app.</p>
<p>I got out the Android SDK, and I figured out the notification was coming from the Bloat Freezer tool! After a few searches I find <a href="http://androidunderground.blogspot.com/2011/12/bloat-freezer-abuses-airpush-ads-to_22.html">a article</a> about how that tool is using a push notification system, AirPush, to send me spam.</p>
<p>I have now removed this app, and writing this blog entry to helpful save others from this hassle.</p>
</description>
    </item>
    
    <item>
      <title>Android Linux SDK revision 6 aapt library bug</title>
      <link>https://blog.bramp.net/post/2010/05/23/android-linux-sdk-revision-6-aapt-library-bug/</link>
      <pubDate>Sun, 23 May 2010 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2010/05/23/android-linux-sdk-revision-6-aapt-library-bug/</guid>
      <description><p><strong>UPDATE – I <a href="http://code.google.com/p/android/issues/detail?id=8498">reported this bug</a> and it was promptly fixed the next day. Read the <a href="http://code.google.com/p/android/issues/detail?id=8498">bug report</a> for solution on how to fix.</strong></p>
<p><a href="http://android-developers.blogspot.com/2010/05/android-22-and-developers-goodies.html">Android 2.2</a> just came out and along with it came a updated set of <a href="http://developer.android.com/sdk/tools-notes.html">SDK tools</a>. I’ve been using these tools on Windows, but today I took my Linux laptop out and I’ve been sat in a <a href="http://www.juicafe.co.uk/">coffee shop</a> hyped up on caffeine but completely unproductive because I’m going round in circles with what I think is a bug.</p>
<p>So, I’m trying the <a href="http://developer.android.com/guide/developing/other-ide.html#libraryProject">new library feature</a>, where you can have a Android library project, which is referenced by one or more Android projects. This allows multiple projects to easily share the same code. The problem is when I set-up my Android project to use a library project I get the following error printed in my eclipse console:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">ERROR: Unknown option &#39;--auto-add-overlay&#39;
</span></span><span class="line"><span class="cl">Android Asset Packaging Tool
</span></span></code></pre></div><p>and the code fails to compile. If I remove the reference to the library project this error goes away.</p>
<p>The error is coming from the aapt command, which seems to be installed multiple times, once for each SDK version:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ locate -r <span class="s2">&#34;aapt</span>$<span class="s2">&#34;</span>
</span></span><span class="line"><span class="cl">/home/bramp/android-sdk-linux_86/platforms/android-3/tools/aapt
</span></span><span class="line"><span class="cl">/home/bramp/android-sdk-linux_86/platforms/android-4/tools/aapt
</span></span><span class="line"><span class="cl">/home/bramp/android-sdk-linux_86/platforms/android-7/tools/aapt
</span></span><span class="line"><span class="cl">/home/bramp/android-sdk-linux_86/platforms/android-8/tools/aapt
</span></span></code></pre></div><p>Checking each command I see that only versions 7 and 8 have the <em>–auto-add-overlay</em> option. Both my library and main projects are targeted at Android 1.6 (i.e. android-4). I tried re-targeting my main project to Android 2.2 (i.e. android-8) and the problem seems to go away.</p>
<p>So for the moment this seems an annoyance, but I can live with it by setting my target to 2.2. Hopefully Google will release a fix so I can still use the older targets with the new library feature.</p>
<p><strong>Just a quick update:</strong><br>
I noticed that on Windows all versions of the aapt tool support the ‘–auto-add-overlay’ option. So what I suspect has happened is that someone forgot to update the aapt binary for the old platforms.</p>
</description>
    </item>
    
    <item>
      <title>Foursquare Rules</title>
      <link>https://blog.bramp.net/post/2009/12/06/foursquare-rules/</link>
      <pubDate>Sun, 06 Dec 2009 00:00:00 +0000</pubDate>
      
      <guid>https://blog.bramp.net/post/2009/12/06/foursquare-rules/</guid>
      <description><p>Everyone plays <a href="http://foursquare.com/">foursquare</a> (the location based android/iPhone app) differently. However, there are no offical rules on what venues are acceptable, and when you can and can’t check-in. So I wanted to write down the rules that I play by:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">1. You talk about foursquare.
</span></span><span class="line"><span class="cl">2. You talk about foursquare.
</span></span><span class="line"><span class="cl">3. When someone is near by you go find them.
</span></span><span class="line"><span class="cl">4, Get as many people to a check-in as possible.
</span></span><span class="line"><span class="cl">5. One check-in at a time.
</span></span><span class="line"><span class="cl">6. Check-in with Android, iPhone, or Blackberry devices.
</span></span><span class="line"><span class="cl">7. You check-in as long and late as you can.
</span></span><span class="line"><span class="cl">8. If this is your first night at foursquare, you have to check-in.
</span></span></code></pre></div><p>Ok, so that was my attempt of humour by parodying the <a href="http://www.diggingforfire.net/FightClub/">rules of fight club</a>.</p>
<p>I actually do play by a set of rules</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">1. I only check-in to venues where I&#39;m using their service. For example, I only 
</span></span><span class="line"><span class="cl">  check-in to a coffee shop if I buy a drink, or I check-in to a train station
</span></span><span class="line"><span class="cl">  only if I get on or off a train.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">2. I don&#39;t check into venues which I am passing though. For example, if my train 
</span></span><span class="line"><span class="cl">  goes through a train station, but I&#39;m staying on the train I won&#39;t check-in. 
</span></span><span class="line"><span class="cl">  Or if my girlfriend is dragging me around clothes shops, I won&#39;t check-in 
</span></span><span class="line"><span class="cl">  unless I&#39;m actually buying something myself.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">3. I only check-in to real stationary public venues. I don&#39;t add my house, or
</span></span><span class="line"><span class="cl">  other made up places, and I don&#39;t check-in into venues such as the number 
</span></span><span class="line"><span class="cl">  2 bus.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">4. I don&#39;t check-in after the fact, for example if I forget at the time to 
</span></span><span class="line"><span class="cl">  check-in. For example, I was recently in Belgium, and I had pre-added a few 
</span></span><span class="line"><span class="cl">  places I knew I would be going to, however, I was unable to check-in due to my 
</span></span><span class="line"><span class="cl">  lack of internet :(
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">5. I always add full complete information for any venue I create. Sometimes
</span></span><span class="line"><span class="cl">  when I&#39;m out I&#39;m unable to find the full data, so I fill in as much as I can, and
</span></span><span class="line"><span class="cl">  later when I get back to my PC I make sure I complete the venue&#39;s details
</span></span><span class="line"><span class="cl">  fully.
</span></span></code></pre></div><p>So these are my rules and I’m sure they will evolve as I play the game more. I would love to hear other people’s rules.</p>
</description>
    </item>
    
  </channel>
</rss>
