Android 入门 (一) 试用
Android的版本
android的版本有很多 0.9 ,1.0 ,1.5,1.6,2.0,2.1
09年4月15日 cupcake android 1.5
09年9月15 Donut android 1.6 : linux内核升级到2.6.29。cdma , wvga ,qvga 的支持
支持OpenCore2媒体引擎 , TTS
09年10月28日 android 2.0  Eclair
支持 HTML5 
     Revamped graphics architecture for improved performance that enables better hardware acceleration.

2010年1月 android 2.1 Flan
        features 和2.0一样,主要是修改一些bugs

Android平台的代码
1 安装工具repo :
curl http://android.git.kernel.org/repo >~/bin/repo
  chmod a+x ~/bin/repo

2 下载平台的代码
代码放在/media/H/android下面
  1. 创建一个目录,放代码:

  mkdir android
  cd android

  2. 运行 repo init 下载最新的源代码:

   repo init -u git://android.git.kernel.org/platform/manifest.git

  3. 当提示输入姓名和E-mail时,输入姓名和gmail的邮件地址。成功后会提示如下信息:

repo initialized in /android

  4 下载

   repo sync
Notes: 如果要下载别的版本的代码,比如cupcake 则在第2步
repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake
下载eclair 则
repo init -u git://android.git.kernel.org/platform/manifest.git -b eclair

android编译
Host : ubuntu 9.04
Java ,javac 版本 1.6
(一) 源码的编译
编译很简单 直接在android目录下 make ,等上5,6小时就可以了,不过android的编译系统要求java,javac的版本是1.5的,在build/core/main.mk里,
会对java,javac的版本进行检测。如果版本不对,则出现问题:

Checking build tools versions...
************************************************************
You are attempting to build with the incorrect version
of java.

Your version is: java version "1.6.0_0".
The correct version is: 1.5.

Please follow the machine setup instructions at
http://source.android.com/download

solution 1 :编辑 build/core/main.mk

修改

java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')

javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.5[\. "$$]')



java_version := $(shell java -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')

javac_version := $(shell javac -version 2>&1 | head -n 1 | grep '[ "]1\.6[\. "$$]')

缺点: 但编译sdk的时候还是会出现问题 。
make sdk
Docs droiddoc: out/target/common/docs/services
javadoc: 错误 - 在 doclet 类 DroidDoc 中,方法 start 已抛出异常 java.lang.reflect.InvocationTargetException
com.sun.tools.javac.code.Symbol$CompletionFailure: 未找到 sun.util.resources.OpenListResourceBundle 的类文件

solition 2:安装1.5版本的jdk:

$ sudo apt-get install sun-java5-jdk flex
$ sudo update-java-alternatives -s java-1.5.0-sun

(二)SDK的编译
在编译完源码后,再执行 make sdk
在out/host/linux-x86/sdk下面有
android-sdk_eng.lawrencekang_linux-x86 android-sdk_eng.lawrencekang_linux-x86.zip sdk_deps.mk


模拟器的运行
现设置好环境变量
export PATH=$PATH:/media/H/android/out/host/linux-x86/bin
export ANDROID_PRODUCT_OUT=/media/H/android/out/target/product/generic
export ANDROID_SWT=/media/H/android/out/host/linux-x86/
然后执行 emulator
用法有:
1 用缺省的virtual device 运行模拟器
emulator
2 用某个皮肤来运行
emulaor -skin QVGA-L
emulator -skin WVGA800 则用WVGA800的皮肤来运行模拟器
但显示 :
emulator: emulator window was out of view and was recentred
我们可以通过-scale ­­选项来解决这个问题,针对我们这个WVGA skin,用./emulator -skin WVGA -scale 0.9来启动模拟器就没问题了
3 直接指定大小
emulator -skin 800x480

不过google的网站http://developer.android.com/上有这样一段话 :
The Android SDK includes several Emulator skins that you can use to control the resolution and density of the emulated device's screen. To select a specific skin for running the emulator, create an AVD that uses that skin. Please do not use deprecated emulator options such as -skin to control the skin used by an emulator instance. For more information about AVDs, see Android Virtual Devices.
意思是最好不要用-skin来运行模拟器,而要用-avd
创建avd用的工具是android
android
出现问题:
Error: Error parsing the sdk.
Error: /media/H/androidcupcake/out/host/linux-x86/platforms is missing.
Error: Unable to parse SDK content.

但在out/host/linux-x86/sdk/android-sdk_eng.lawrencekang_linux-x86/tools目录下 ./android 则可以
原来在out/host/linux-x86/sdk/android-sdk_eng.lawrencekang_linux-x86/下面有platforms目录,可见android会查找
上一级目录下的platforms目录
将platforms 和add-ons copy到 out/host/linux-x86下面
然后运行 android就可以了
创建的avd放在 ~/.android/avd下面
假如创建了一个foo ,则emulator -avd foo

模拟器跑起来后 ,还可以用adb shell 来执行 终端命令。

更多相关文章

  1. Android 模拟器创建参数说明
  2. 在eclipse中查看android SDK的源代码
  3. Android 高管谈 Lollipop:为何它是 Android 重大版本更新?
  4. Android彻底组件化—代码和资源隔离
  5. 获取Android的Java源代码并在Eclipse中关联查看的最新方法
  6. 生成release版本的Android係統
  7. NDK版本与Android固件要求对应表
  8. Android API版本对应Android系统版本及内核版本和代号
  9. Android版本演进史

随机推荐

  1. 打造Android的中文Siri语音助手(一)——
  2. Android偷偷进了PC村,Google是无心插柳还
  3. Android图像滤镜框架GPUImage从配置到应
  4. Android应用程序线程消息循环模型分析
  5. Android线程模型解析(包括UI的更新)
  6. [Android]使用ActivityGroup来切换Activi
  7. >>>PayPal支持Android与iPhone的说明 请
  8. android 内部文件读取
  9. Android-自定义滑动菜单(抽屉效果)
  10. android如何实现类似ios点击状态栏回到顶