You are attempting to build with the incorrect version of java.

来源:互联网 发布:笔记本摄像头监控软件 编辑:程序博客网 时间:2024/05/29 02:12

   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/上有这样一段话 :
TheAndroid SDK includes several Emulator skins that you can use to controlthe resolution and density of the emulated device's screen. To select aspecific skin for running the emulator, create an AVD that uses thatskin. Please do not use deprecated emulator options such as -skin tocontrol the skin used by an emulator instance. For more informationabout 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 来执行 终端命令。

原创粉丝点击