Category: Hacking

Fixing APK Compile Error

I have been trying to change, decompile, and recompile Trebuchet to change the items on the dock and home screen.  I keep getting errors, and I think I have finally found the solution.

The output of the command is quite long, so let me post the beginning:

[sourcecode]

skp@chestnut:~/app/hd2/dev/work$ apktool b Trebuchet-orig Trebuchet.apk
I: Copying classes.dex file…
I: Checking whether resources has changed…
I: Building resources…
invalid resource directory name: /home/skp/app/hd2/dev/work/Trebuchet-orig/res/values-sw720dp-land
invalid resource directory name: /home/skp/app/hd2/dev/work/Trebuchet-orig/res/drawable-sw600dp-nodpi
invalid resource directory name: /home/skp/app/hd2/dev/work/Trebuchet-orig/res/drawable-sw600dp-land-hdpi[/sourcecode]

And, here’s the end of the output:

[sourcecode]

invalid resource directory name: /home/skp/app/hd2/dev/work/Trebuchet-orig/res/layout-sw720dp
Exception in thread "main" brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, -F, /tmp/APKTOOL1399953021396634018.tmp, -I, /home/skp/apktool/framework/1.apk, -S, /home/skp/app/hd2/dev/work/Trebuchet-orig/res, -M, /home/skp/app/hd2/dev/work/Trebuchet-orig/AndroidManifest.xml]
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:193)
at brut.androlib.Androlib.buildResourcesFull(Androlib.java:301)
at brut.androlib.Androlib.buildResources(Androlib.java:248)
at brut.androlib.Androlib.build(Androlib.java:171)
at brut.androlib.Androlib.build(Androlib.java:154)
at brut.apktool.Main.cmdBuild(Main.java:182)
at brut.apktool.Main.main(Main.java:67)
Caused by: brut.common.BrutException: could not exec command: [aapt, p, -F, /tmp/APKTOOL1399953021396634018.tmp, -I, /home/skp/apktool/framework/1.apk, -S, /home/skp/app/hd2/dev/work/Trebuchet-orig/res, -M, /home/skp/app/hd2/dev/work/Trebuchet-orig/AndroidManifest.xml]
at brut.util.OS.exec(OS.java:83)
at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:191)
… 6 more[/sourcecode]

What I finally found, was that I installed an old or invalid version of aapt with apktool.  It was installed into /usr/local/bin…

[sourcecode]

skp@chestnut:~/app/hd2/dev/work$ which aapt
/usr/local/bin/aapt
skp@chestnut:~/app/hd2/dev/work$ ll `which aapt`
-rwxr-x— 1 skp skp 3747857 May 15 2011 /usr/local/bin/aapt*[/sourcecode]

The easy fix was to just rename this one installed with apktool.  Then, it pulled the one from my Android SDK intallation. (I already had the platform-tools directory in the path.)

[sourcecode]

skp@chestnut:~/app/hd2/dev/work$ cd /usr/local/bin/
skp@chestnut:/usr/local/bin$ sudo mv aapt aapt-broken
[sudo] password for skp:
skp@chestnut:/usr/local/bin$ which aapt
/home/skp/app/android-sdk-linux/platform-tools/aapt[/sourcecode]

After that, it compiled fine!

[sourcecode]
skp@chestnut:~/app/hd2/dev/work$ apktool b Trebuchet-orig Trebuchet.apk
I: Checking whether resources has changed…
I: Building resources…
I: Building apk file…
[/sourcecode]

HD2 Android Cooking

This is my first delve into cooking my own ROM for HD2.  I am not at a point where I can give step-by-step directions, but I wanted to post some of the things that I figured out so far.

Danial’s (dsixda) Android Kitchen

I have heard a lot about the Android Kitchen, so I thought I would try it.  It was an easy install.  I just had to download the zip file from Git Hub and extract it into a directory:

To launch it, I go to that directory in a terminal…

… and run the ./menu command.  That brings up the Kitchen menu.

Importing My First ROM

I started with the Paranoid Android – AOKP – Sourcery ROM.  I simply downloaded it, and placed it in the

Then, on the menu, I chose option 1 to create the working folder.

When it was done, it created this working directory:

Adding My First App

Just to make a small easy change, I decided to add an app to the ROM.  I have been using the Wifi Tether program, and I decided to bake that into the ROM.  It was as easy as placing it into the working folder under data/app.

This worked fine, but for some reason, the wireless tethering won’t work on my ROM.  The app works fine, but when it tethers, it gets an error.   That’s an issue for troubleshooting another day.

Changing the Default Background

I found some instructions that suggested using the apktool program to update the background.  But, rather than that, I just used the File Roller to extract and replace the files in the apk file.

I found the framework-res.apk file inside the system/framework folder in the working directory.  I opened the file with file-roller and I went to the /res/drawable-hdpi folder.  There I extracted the default_wallpaper.jpg.

I simply edited the image with Gimp and replaced it in the apk file.

This worked great at first.  Then, my old wallpaper mysteriously reappeared.  I assume that was from Google’s syncing my phone to previous setups.

Adding Chrome By Default

I unzipped my Titanium backup of Chrome to the System directory.

This made Chrome show up in the list, but it failed to run.  I ended up moving it to the /data/app folder of the ROM, and that fixed the problem.  Chrome was installed by default.

Note: I did the same thing with Swype.  I found it also had to go in the /data/app folder.

Changing the Launcher

The ROM that I started with has the Nova Launcher in it.  I did a little reading up on launchers, and I decided to try to the Go Launcher EX.

First, I removed the Nova Launcher.  I deleted the NovaLauncher.apk file:

I tried to download the Go Launcher from their website, but it mostly sent me to the market.  Instead, I installed it from the Market.  Then, I pulled it off the phone with adb.

[sourcecode]adb pull /data/app/com.gau.go.launcherex-1.apk
adb pull /data/app/com.gau.go.launcherex.gowidget.weatherwidget-1.apk[/sourcecode]

I simply removed the NovaLauncher.apk from the /system/app folder.  Then, I added these two apk files in its place.  That gave me the Go launcher.

I tried that out for a bit, but then I decided to go back to Trebuchet.  So, I swapped the two Go apk files with Trebuchet.apk from another CM10 ROM.

Building the ROM

After all this, I built the ROM from the kitchen.  I just used option #99.

Then, I picked option#1, the interactive mode.  Then, I took the defaults.  It creates the zip file in the output zip folder.

I had a problem with the ROM flashing.  I think that it has to do with the “if” statements in the update script.  The kitchen didn’t translate it correctly.  So, I replaced the update script with the original script from the original ROM.

Later, I went back into it and found that I could remove the if, else, and end-if lines from the update-script in the working folder.  This takes out the feature that autodetects CLK vs. MagLdr.  But, it flashes on my phone fine.  I can figure that out later.

Resources

Troubleshooting: Fixing Mono Compiler Issue

I tried to open Gnome-RDP in Monodevelop, and this is the error that I get:

Could not obtain a C# compiler.  C# compiler not found for Mono / .NET 3.5.

Could not obtain a c# compiler.  C# compiler not found for Mono / .NET 3.5.

The fix is to simply change the compiler target on the project’s properties.  Right click on the project and choose “Options”.

MonoDevelop - Project Options Menu

Then, change the runtime version.

Project Options, Runtime Version

Changing it to 4.0 fixes the project.

4.0 Version

You may need to accept a message like this:

Select File Format

References

Ask Ubuntu: Could not obtain c# compiler error when using monodevelop

Paying Attention to Licenses

This article kind of caught my attention:

InfoWorld — Study: 70 percent of iPhone and Android open source apps violate licenses

The Open Source license isn’t the fun part of the project.  I like to be creative, and I like to see the program work.  Worrying about a license is the last thing I want to do, but it needs to be done.

So, here are some places to start researching:

I found a little bit of a checklist on this page under the section Applying the License, but I would like a better checklist specific to the Apache License 2.0.

Great Link: Teaching Open Source

Yesterday, I came across this Teaching Open Source website while reading Max Spevax’s Post.  Here are some of the different things I found on the site:

The textbook is the biggest thing.  Right now, you can go look at Version 0.8 of their textbook.  This is something I need to go through.

Adding Custom Emblems to Your Folder Icons

I have a work folder under my Home folder that I store all of my work-related documents.  I wanted to put my work’s logo on the folder to make it stand out.

I found a great thread with some tips.  Basically, I downloaded a graphic from the company website with the logo on it.  I used Gimp to crop and resize it.  Then, I saved it to the folder: $HOME/.icons/hicolor/48×48/emblems (I had to create the .icons directory).  Finally, when I right clicked on the folder and viewed the property, my new icon was in the list of emblems.

Hacking Gnome-RDP

The Gnome-RDP application has been very helpful to me in connecting to various remote machines.  So, I have been trying to contribute a few changes here and there.  Here is how I have been making my patches to contribute:

Step 1: Check out the Source Code

svn co https://gnome-rdp.svn.sourceforge.net/svnroot/gnome-rdp gnome-rdp

Step 2: Create a copy for comparing

cp -r gnome-rdp gnome-rdp-compare

Step 3: Compare and Copy my changes into what I checked out

meld previous/gnome-rdp-svn/branches/experimental gnome-rdp/branches/experimental/

Step 4: Create the patch

diff -Naur gnome-rdp-compare/branches/experimental/ gnome-rdp/branches/experimental/ > change.patch

Step 5: Publish the Patch

I created a new bug in the launchpad bug tracker, and I attached the patch there.

Here are the patches I have done so far:

I am most definitely welcome to suggestions for anything that I am doing wrong or could do easier.