![]() | |||||
| Android Debugging |
If you read this, most likely you've tried to debug something on Android and found out it's not as easy as you would have wanted it to be.
Here's a short tutorial, from my memory to get it working. If I forgot something, please write it down in the comments and I will keep this post updated.
First, There are many mistakes that can be made. The documentation/instructions and warnings under Google's Android website are less useful and you can find yourself compiling the whole environment of Android 2.1 on Ubuntu 8.04 (which is a very big mistake, and you'll waste your time - so don't do it!).
Make sure you use latest Ubuntu (I'm not a big fan of Ubuntu, as a Slackware user for the last 10 years, but apt-get just does a good job in this setup) to build latest Android.
Download Android using GIT & REPO:
repo init -u git://android.git.kernel.org/platform/manifest.git -b <version>
e.g :
repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair
This should take a few hours... ;)
Compile Webkit with debugging flags, I'm quite sure this link was helpful, but I also quite sure there were few mistakes which I don't remember, I do remember it wasn't perfect buildspec.mk so just change it to fit your debugging needs.
The link had the following instructions:
Debug Native C++ Code:
To get meaningful debug info, you do need to build WebCore with -
O0. It is simple. Add the following to your buildspec.mk and rebuild webcore and xml2.
Use "rm out/target/product/dream/system/build.prop" (zuk's comment: I'm also sure they had path mistakes ;), take that into considerations) to make sure it takes effect.
To rebuild webcore and xml2:
make clean-libwebcore clean-libxml2 && make //DO NOT DO THAT YET!!!
Prepare your environment by downloading all the right packages at once (all in one line! yey!):
sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libreadline5-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev build-essential
uninstall java, and install java 1.5:
sudo update-java-alternatives -s java-1.5.0-sun
"If you don't have buildspec.mk under the root directory yet, please copy build/buildspec.mk.default to the root (android/)
Change to the following lines :
DEBUG_MODULE_libwebcore:=true
DEBUG_MODULE_libxml2:=true
TARGET_CUSTOM_DEBUG_CFLAGS:=-O0 -mlong-calls
Add "ADDITIONAL_BUILD_PROPERTIES += debug.db.uid=100000" so that it
will wait for you to connect gdb when crashed.
in Webkit folder (for eclair branch only):
git commit / stash
git cherry-pick 18342a41ab72e2c21931afaaab6f1b9bdbedb9fa
Environment setup (fix paths if needed):
export PATH="/usr/lib/jvm/java-1.5.0-sun-1.5.0.22/:$PATH"
export JAVA_HOME="/usr/lib/jvm/java-1.5.0-sun-1.5.0.22"
export ANDROID_JAVA_HOME=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
chmod +x ./build/env-setup.sh
source ./build/env-setup.sh #make sure you use the source command and not trying to execute the file itself...
make clean-libwebcore clean-libxml2; make
Now debugging will be made possible using gdbserver, adb and gnu-arm-eabi-gdb client (use latest gdb! they had tons of bug fixes - great job!).
You will also be able to compile native code easily by having Android.mk and executing:
source /path/to/androidhome/build/env-setup.sh;
mm;
Happy debugging



6 comments:
Thank you, i am trying to debug on Android. Your post is very interesting.
Hi! i'm trying this thing but still breakpoints are not working for me, just receive a SIGBREAK and closes the app. My breakpoints are on libwebcore.
Have any idea? is this working for you?
thanks!.
please specify which version of gdb are you using,
also, are you sure you've followed the instructions and did you load the symbols to GDB?
would love to get this up `n going, but since the kernel.org debacle everything I've read says to use github.com for the manifest... but trying that gives this error (any ideas?);;
repo init -uhttps://github.com/android/platform_manifest.git
[<<<----SNIP---->>>]
Getting repo ...
from git://android.git.kernel.org/tools/repo.git
fatal: Unable to look up android.git.kernel.org (port 9418) (Name or service not known)
Exit 1
thanks for the great post.
I had to set
TARGET_PRELINK_MODULE:=false
in build/core/config.mk
because of prelink map error libwebcore is too big.
Excellent pieces. Keep posting such kind of information on your blog. I really impressed by your blog.
WINDOWS PHONE 7 DEVELOPMENT
Post a Comment