分类: LINUX
2009-12-03 13:03:46
I was devastated by Android these days
let me organize some noticeable points here
(ubuntu 8.10 is used)
1. download Android source code (cupcake)
create home:
:mkdir AndroidHome
install Git:
:sudo apt-get install git-core
install Repo:
:curl http://android.git.kernel.org/repo > ~/AndroidHome/bin/repo
:chmod a+x ~/AndroidHome/bin/repo
install Python:
:sudo apt-get install python
install JDK 1.6:
:cd ~/AndroidHome/downloads
:chmode a+x jdk-6u11-linux-i586.bin
:.jdk-6u11-linux-i586.bin
:cp -R jdk1.6.0_11/ /usr/local/jdk1.6.0_11/
add followings to ~/.bashrc:
:export PATH=/usr/local/jdk1.6.0_11/bin:$PATH
:export JAVA_HOME=/usr/local/jdk1.6.0_11
:export ANDROID_JAVA_HOME=$JAVA_HOME
start to download:
:cd ~/AndroidHome/
:repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
(or :repo init -u git://android.git.kernel.org/platform/manifest.git -b release-1.0 for older version)
:repo sync
2. make Android source code
:make
The following error occurs
external/qemu/sockets.c: In function ?sock_address_init_resolve?:
external/qemu/sockets.c:637: error: ?EAI_NODATA? undeclared (first use
in this function)
external/qemu/sockets.c:637: error: (Each undeclared identifier is
reported only once
external/qemu/sockets.c:637: error: for each function it appears in.)
solution:
add “#if …” and “#endif” before and after case EAI_NODATA in sockets.c
#if defined(EAI_NODATA) && EAI_NODATA != EAI_NONAME
case EAI_NODATA:
#endif
case EAI_NONAME:
err = ENOENT;
break;
after that, another ploblem occurs
the process is killed while making dex file
the reason is that the memory is not enough
it seams that at least 1.5G RAM and 10G HD space is required
so I setup the swap space to 2G
:dd if=/dev/zero of=/swapfile bs=1024 count=2000000
:mkswap /swapfile
:swapon /swapfile
:/swapfile swap swap defaults 0 0
finally, the make finished, which took about 4~6 hours
after the build success, the apk files will be in out/target/product/generic/system/app
3. make SDK
** important: JDK 1.5, not 1.6, must be used **
otherwise, the following error will occur:
javadoc: error – In doclet class DroidDoc, method start has thrown an
exception java.lang.reflect.InvocationTargetException
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for
sun.util.resources.OpenListResourceBundle not found
1 error
make: *** [out/target/common/docs/dx-timestamp] Error 45
:make sdk
4. make ADT
If you use Android 1.5 SDK, you have to update the ADT to 0.9.0
Otherwise, there will errors occur
Normally, the update of ADK can be done easily through the “Software Updates” in eclipse
However, the ADT server cannot be connected to these days
Even the older version (0.8.0) is also not available
So, you have to make it by yourself
:development/tools/eclipse/scripts/build_server.sh ~/adt/
And then, how to install it into the eclipse?
choose “help” -> “Software Updates” -> “Add Site” -> “Local”
and then select the folder of ADT
5. create AVD (Android Virtual Device)
you have to create AVD for, otherwise, eclipse may display the following error:
Failed to find an AVD compatible with target ‘Android 1.5′. Launch aborted.
D:\Android SDK\android-sdk-windows-1.5_r1\tools>android list
D:\Android SDK\android-sdk-windows-1.5_r1\tools>android create avd –name aid15r1 –target 2
6. build module to APK
:cd ~/AndroidHome/src
:. build/envsetup.sh
:mmm packages/apps/Contacts/
p.s. however, if there is any import from another module in the current module, I still cannot build it successfully …
7. build your module in elipse
first of all, place your srource codes in packages/apps/YourModuleName/src
:cd /AndroidHome
:cp development/ide/eclipse/.classpath .
:chmod u+w .classpath
Now edit that copy of .classpath, if necessary.
in eclipse:
File > New > Java Project
enter your project name
Select “Create project from existing source”, enter the path to your Android root directory, and click Finish.
if it doesn’t start to build, uncheck and re-check Project > Build Automatically to force a rebuild
Project > Properties
Select “Java Build Path” from the left-hand menu.
Choose the “Source” tab.
Click “Add Folder…”.
Add your module’s “src” directory.
Click OK.
After the build success, the class file will be in out/target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates/classes
p.s. I still don’t know how to build the apk file of my module in eclipse …
8. deal with devices/emulators
enter the device:
>adb shell
list directories/files:
#ls
system applications are mainly in /system/app/
install apk:
>adb install YourAPK.apk
installed apk will be placed in /data/local/tmp
push data into device:
>adb push test.txt /tmp/test.txt
** you cannot push apk files into /system/app/ on real device**
if you push files into /system/app/ on emulator, the following error may occur:
failed to copy ‘xxx.apk’ to ’system/app/xxx.apk’: Read-only file system
solution:
>adb remount
get data from device:
>adb pull /addroid/lib/libwebcore.so .
9. build the system image
:make snod
[References]
android.com/download
android-platform/browse_thread/thread/153e2155e33c6555
http://www.dubblogs.cc/roller/Android/entry/test
android/build.html
~richardlin/blog/?p=7
http://547600.javaeye.com/blog/368166
http://blog.chinaunix.net/u2/85805/showart_1897152.html
http://www.cppblog.com/kaisne/archive/2009/04/29/81493.html
android.com/using-eclipse
http://stenlyho.blogspot.com/2008/11/androidadb.html
android-developers@googlegroups.com/msg08828.html
http://blog.chinaunix.net/u2/86601/showart.php?id=1885062
http://blog.csdn.net/HKjinzhao/archive/2009/03/18/4002326.aspx
http://planet.nccucs.org/2008/09/04/678/
http://lotushy.blogspot.com/2008/10/android-sdk-developing-android.html
http://www.rankolife.cn/blog-280.html
http://forum.xda-developers.com/showthread.php?t=507244&page=42
http://blog.ring.idv.tw/comment.ser?i=252
android-framework/browse_thread/thread/7d43ce3cdbac35a8
android-platform/browse_thread/thread/de555a2f3029ab1a
張貼於