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

來源:互聯網
上載者:User

   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 來執行 終端命令。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.