ubuntu+vmware上运行android+java小记

来源:互联网 发布:javascript的写法 编辑:程序博客网 时间:2024/04/29 18:49

1:sudo passwd

更改root密码

 

2:root登陆

在系统安全设置里使能administrator登陆,重启并以root登陆

 

3:java 环境建立

复制android-source/jdk-1_5_0_17-linux-i586.bin 到主机linux 的home/james目录,在终端中进
入到相应目录下,分别执行以下操作:
./jdk-1_5_0_17-linux-i586.bin
修改/etc/bash.bashrc:
gedit /etc/bash.bashrc
增加以下内容:
export JAVA_HOME=/home/james/jdk1.5.0_17
export ANDROID_JAVA_HOME=$JAVA_HOME
export PATH=$JAVA_HOME/bin:$PATH

 

4:cupcake 源码包的建立

复制cupcake-1.5.2.tar.bz2 到linux 的home/james 目录下

在james目录下运行tar –jvxf cupcake-1.5.2.tar.bz2
得到cupcake-1.5.2 目录

 

5:Android SDK 的建立

复制android-source/android-sdk-1.5.tar.bz2 到linux 的home/james 目录下tar –jvxf android-sdk-1.5.tar.bz2
得到android-sdk-1.5 目录,修改/etc/bash.bashrc:
gedit /etc/bash.bashrc
增加以下内容:
export PATH=/home/james/android-sdk-1.5/tools:$PATH

 

6:Eclipse 的建立

复制android-source/ eclipse-android.tar.bz2 到linux 的home/james 目录下,进入相应目录,在
终端分别进行以下操作:

tar –jvxf eclipse-android.tar.bz2
得到eclipse 目录,修改/etc/bash.bashrc:
gedit /etc/bash.bashrc
增加以下内容:
export PATH=/home/james/eclipse:$PATH
根据实际情况填写路径,保存退出
输入
source /etc/bash.bashrc
使上面的环境变量设置生效,这时候可能需要关闭当前终端并新开一个终端才能生效

 

7:root@james:~# java -version
java version "1.5.0_17"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_17-b04)
Java HotSpot(TM) Client VM (build 1.5.0_17-b04, mixed mode, sharing)

8:root@james:~# emulator
emulator: ERROR: You did not provide the name of an Android Virtual Device
with the '-avd <name>' option. Read -help-avd for more information.

If you *really* want to *NOT* run an AVD, consider using '-data <file>'
to specify a data partition image file (I hope you know what you're doing).

 

9:root@james:~# eclipse
如果成功可以看到eclipse界面

 

10:Android 源码包的编译

root@james:/home/james/cupcake-1.5.2# pwd
/home/james/cupcake-1.5.2
root@james:/home/james/cupcake-1.5.2# make

build/core/product_config.mk:261: WARNING: adding test OTA key
============================================
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=
============================================
/bin/bash: bison: command not found

 

出错apt-get install bison

install bisom后再

root@james:/home/james/cupcake-1.5.2# make

 

又出现如下错误

============================================
make: execvp: /bin/bash: Argument list too long
host C: acp <= build/tools/acp/acp.c
build/tools/acp/acp.c:11:20: error: stdlib.h: No such file or directory
build/tools/acp/acp.c:12:19: error: stdio.h: No such file or directory
build/tools/acp/acp.c:13:20: error: string.h: No such file or directory
build/tools/acp/acp.c:14:20: error: unistd.h: No such file or directory
build/tools/acp/acp.c:15:23: error: sys/types.h: No such file or directory
build/tools/acp/acp.c:16:22: error: sys/stat.h: No such file or directory
build/tools/acp/acp.c:17:20: error: getopt.h: No such file or directory
build/tools/acp/acp.c:18:20: error: dirent.h: No such file or directory
build/tools/acp/acp.c:19:19: error: fcntl.h: No such file or directory
build/tools/acp/acp.c:20:19: error: utime.h: No such file or directory
In file included from /usr/lib/gcc/i486-linux-gnu/4.2.3/include/syslimits.h:7,
                 from /usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h:11,
                 from build/tools/acp/acp.c:21:
/usr/lib/gcc/i486-linux-gnu/4.2.3/include/limits.h:122:61: error: limits.h: No such file or directory
build/tools/acp/acp.c:22:19: error: errno.h: No such file or directory
build/tools/acp/acp.c:23:20: error: assert.h: No such file or directory
build/tools/acp/acp.c: In function ‘process’:
build/tools/acp/acp.c:45: error: ‘NULL’ undeclared (first use in this function)
build/tools/acp/acp.c:45: error: (Each undeclared identifier is reported only once
build/tools/acp/acp.c:45: error: for each function it appears in.)
build/tools/acp/acp.c:47: error: storage size of ‘destStat’ isn’t known
build/tools/acp/acp.c:49: error: storage size of ‘sb’ isn’t known
build/tools/acp/acp.c:51: warning: implicit declaration of function ‘assert’
build/tools/acp/acp.c:61: warning: implicit declaration of function ‘strlen’
build/tools/acp/acp.c:61: warning: incompatible implicit declaration of built-in function ‘strlen’
build/tools/acp/acp.c:62: warning: implicit declaration of function ‘malloc’
build/tools/acp/acp.c:62: warning: incompatible implicit declaration of built-in function ‘malloc’
build/tools/acp/acp.c:63: warning: implicit declaration of function ‘memcpy’
build/tools/acp/acp.c:63: warning: incompatible implicit declaration of built-in function ‘memcpy’
build/tools/acp/acp.c:80: warning: implicit declaration of function ‘stat’
build/tools/acp/acp.c:82: error: ‘errno’ undeclared (first use in this function)
build/tools/acp/acp.c:82: error: ‘ENOENT’ undeclared (first use in this function)
build/tools/acp/acp.c:83: warning: implicit declaration of function ‘fprintf’
build/tools/acp/acp.c:83: warning: incompatible implicit declaration of built-in function ‘fprintf’
build/tools/acp/acp.c:83: error: ‘stderr’ undeclared (first use in this function)
build/tools/acp/acp.c:92: warning: implicit declaration of function ‘S_ISDIR’
build/tools/acp/acp.c:96: warning: incompatible implicit declaration of built-in function ‘fprintf’
build/tools/acp/acp.c:130: warning: implicit declaration of function ‘strrchr’
build/tools/acp/acp.c:130: warning: incompatible implicit declaration of built-in function ‘strrchr’
build/tools/acp/acp.c:159: warning: implicit declaration of function ‘free’
build/tools/acp/acp.c: In function ‘main’:
build/tools/acp/acp.c:184: warning: implicit declaration of function ‘getopt’
build/tools/acp/acp.c:214: warning: incompatible implicit declaration of built-in function ‘fprintf’
build/tools/acp/acp.c:214: error: ‘stderr’ undeclared (first use in this function)
build/tools/acp/acp.c:225: error: ‘optind’ undeclared (first use in this function)
build/tools/acp/acp.c:226: warning: incompatible implicit declaration of built-in function ‘fprintf’
build/tools/acp/acp.c:232: warning: incompatible implicit declaration of built-in function ‘fprintf’
make: *** [out/host/linux-x86/obj/EXECUTABLES/acp_intermediates/acp.o] Error 1

root@james:/home/james/cupcake-1.5.2# apt-get install build-essential

会出来如下一系列包的安装

Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following extra packages will be installed:
  cpp-4.2 dpkg-dev g++ g++-4.2 gcc-4.2 gcc-4.2-base libc6 libc6-dev libc6-i686
  libffi4 libgcc1 libgomp1 libstdc++6 libstdc++6-4.2-dev libtimedate-perl
  linux-libc-dev patch
Suggested packages:
  gcc-4.2-locales debian-keyring g++-multilib g++-4.2-multilib gcc-4.2-doc
  libstdc++6-4.2-dbg gcc-4.2-multilib libgcc1-dbg libgomp1-dbg
  libmudflap0-4.2-dev libmudflap0-dbg glibc-doc manpages-dev
  libstdc++6-4.2-doc diff-doc
The following NEW packages will be installed:
  build-essential dpkg-dev g++ g++-4.2 libc6-dev libstdc++6-4.2-dev
  libtimedate-perl linux-libc-dev patch
The following packages will be upgraded:
  cpp-4.2 gcc-4.2 gcc-4.2-base libc6 libc6-i686 libffi4 libgcc1 libgomp1
  libstdc++6
9 upgraded, 9 newly installed, 0 to remove and 343 not upgraded.
Need to get 17.8MB of archives.
After this operation, 34.3MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1
http://us.archive.ubuntu.com hardy-updates/main libgomp1 4.2.4-1ubuntu4 [12.3kB]
Get:2
http://us.archive.ubuntu.com hardy-updates/main gcc-4.2-base 4.2.4-1ubuntu4 [100kB]
Get:3
http://us.archive.ubuntu.com hardy-updates/main libgcc1 1:4.2.4-1ubuntu4 [23.3kB]
Get:4
http://us.archive.ubuntu.com hardy-updates/main libffi4 4.2.4-1ubuntu4 [13.0kB]
Get:5
http://us.archive.ubuntu.com hardy-updates/main cpp-4.2 4.2.4-1ubuntu4 [2486kB]
Get:6
http://us.archive.ubuntu.com hardy-updates/main gcc-4.2 4.2.4-1ubuntu4 [596kB]
Get:7
http://us.archive.ubuntu.com hardy-updates/main libstdc++6 4.2.4-1ubuntu4 [332kB]
Get:8
http://us.archive.ubuntu.com hardy-updates/main libc6 2.7-10ubuntu5 [4307kB]
Get:9
http://us.archive.ubuntu.com hardy-updates/main libc6-i686 2.7-10ubuntu5 [1243kB]
Get:10
http://us.archive.ubuntu.com hardy-updates/main linux-libc-dev 2.6.24-27.69 [708kB]
Get:11
http://us.archive.ubuntu.com hardy-updates/main libc6-dev 2.7-10ubuntu5 [3344kB]
Get:12
http://us.archive.ubuntu.com hardy-updates/main libstdc++6-4.2-dev 4.2.4-1ubuntu4 [1187kB]
Get:13
http://us.archive.ubuntu.com hardy-updates/main g++-4.2 4.2.4-1ubuntu4 [2784kB]
Get:14
http://us.archive.ubuntu.com hardy-updates/main g++ 4:4.2.3-1ubuntu6 [1440B]
Get:15
http://us.archive.ubuntu.com hardy/main libtimedate-perl 1.1600-9 [30.1kB]
Get:16
http://us.archive.ubuntu.com hardy/main patch 2.5.9-4 [95.6kB]         
Get:17
http://us.archive.ubuntu.com hardy-updates/main dpkg-dev 1.14.16.6ubuntu4.1 [559kB]
Get:18
http://us.archive.ubuntu.com hardy/main build-essential 11.3ubuntu1 [7066B]
Fetched 17.8MB in 3min30s (84.8kB/s)                                          
Preconfiguring packages ...
(Reading database ... 95877 files and directories currently installed.)
Preparing to replace libgomp1 4.2.3-2ubuntu7 (using .../libgomp1_4.2.4-1ubuntu4_i386.deb) ...
Unpacking replacement libgomp1 ...
Preparing to replace gcc-4.2-base 4.2.3-2ubuntu7 (using .../gcc-4.2-base_4.2.4-1ubuntu4_i386.deb) ...
Unpacking replacement gcc-4.2-base ...
Setting up gcc-4.2-base (4.2.4-1ubuntu4) ...

(Reading database ... 95877 files and directories currently installed.)
Preparing to replace libgcc1 1:4.2.3-2ubuntu7 (using .../libgcc1_1%3a4.2.4-1ubuntu4_i386.deb) ...
Unpacking replacement libgcc1 ...
Setting up libgcc1 (1:4.2.4-1ubuntu4) ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place
(Reading database ... 95877 files and directories currently installed.)
Preparing to replace libffi4 4.2.3-2ubuntu7 (using .../libffi4_4.2.4-1ubuntu4_i386.deb) ...
Unpacking replacement libffi4 ...
Preparing to replace cpp-4.2 4.2.3-2ubuntu7 (using .../cpp-4.2_4.2.4-1ubuntu4_i386.deb) ...
Unpacking replacement cpp-4.2 ...
Preparing to replace gcc-4.2 4.2.3-2ubuntu7 (using .../gcc-4.2_4.2.4-1ubuntu4_i386.deb) ...
Unpacking replacement gcc-4.2 ...
Preparing to replace libstdc++6 4.2.3-2ubuntu7 (using .../libstdc++6_4.2.4-1ubuntu4_i386.deb) ...
Unpacking replacement libstdc++6 ...
Setting up libstdc++6 (4.2.4-1ubuntu4) ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place
(Reading database ... 95876 files and directories currently installed.)
Preparing to replace libc6 2.7-10ubuntu3 (using .../libc6_2.7-10ubuntu5_i386.deb) ...
Unpacking replacement libc6 ...
Setting up libc6 (2.7-10ubuntu5) ...

Processing triggers for libc6 ...
ldconfig deferred processing now taking place
(Reading database ... 95876 files and directories currently installed.)
Preparing to replace libc6-i686 2.7-10ubuntu3 (using .../libc6-i686_2.7-10ubuntu5_i386.deb) ...
Unpacking replacement libc6-i686 ...
Selecting previously deselected package linux-libc-dev.
Unpacking linux-libc-dev (from .../linux-libc-dev_2.6.24-27.69_i386.deb) ...
Selecting previously deselected package libc6-dev.
Unpacking libc6-dev (from .../libc6-dev_2.7-10ubuntu5_i386.deb) ...
Selecting previously deselected package libstdc++6-4.2-dev.
Unpacking libstdc++6-4.2-dev (from .../libstdc++6-4.2-dev_4.2.4-1ubuntu4_i386.deb) ...
Selecting previously deselected package g++-4.2.
Unpacking g++-4.2 (from .../g++-4.2_4.2.4-1ubuntu4_i386.deb) ...
Selecting previously deselected package g++.
Unpacking g++ (from .../g++_4%3a4.2.3-1ubuntu6_i386.deb) ...
Selecting previously deselected package libtimedate-perl.
Unpacking libtimedate-perl (from .../libtimedate-perl_1.1600-9_all.deb) ...
Selecting previously deselected package patch.
Unpacking patch (from .../patch_2.5.9-4_i386.deb) ...
Selecting previously deselected package dpkg-dev.
Unpacking dpkg-dev (from .../dpkg-dev_1.14.16.6ubuntu4.1_all.deb) ...
Selecting previously deselected package build-essential.
Unpacking build-essential (from .../build-essential_11.3ubuntu1_i386.deb) ...
Setting up libgomp1 (4.2.4-1ubuntu4) ...

Setting up libffi4 (4.2.4-1ubuntu4) ...

Setting up cpp-4.2 (4.2.4-1ubuntu4) ...
Setting up gcc-4.2 (4.2.4-1ubuntu4) ...
Setting up libc6-i686 (2.7-10ubuntu5) ...

Setting up linux-libc-dev (2.6.24-27.69) ...
Setting up libc6-dev (2.7-10ubuntu5) ...
Setting up libtimedate-perl (1.1600-9) ...
Setting up patch (2.5.9-4) ...
Setting up dpkg-dev (1.14.16.6ubuntu4.1) ...
Setting up libstdc++6-4.2-dev (4.2.4-1ubuntu4) ...
Setting up g++-4.2 (4.2.4-1ubuntu4) ...
Setting up g++ (4:4.2.3-1ubuntu6) ...

Setting up build-essential (11.3ubuntu1) ...
Processing triggers for libc6 ...
ldconfig deferred processing now taking place

 

root@james:/home/james/cupcake-1.5.2# make

 

出错提示zlib.h没有找到

在ubuntu.iso的pool/main/z/zlib里双击安装包进行安装

再运行如下命令进行编译

root@james:/home/james/cupcake-1.5.2# make

 

提示出错/usr/bin/ld: cannot find -lncurses

安装 root@james:/home/james/cupcake-1.5.2# apt-get install libncurses5-dev

提示X11/Xlib.h:找不到

安装 apt-get install libx11-dev

再make

约三小时编译完成,生成的目标文件在以下目录
home/james/cupcake-1.5.2/out/target/product/generic

11:创建avd

输入以下命令

root@james:/home/james/cupcake-1.5.2# android create avd -n G1-sdk-15 -t 3
Created AVD 'G1-sdk-15' based on Google APIs (Google Inc.)

输入以下命令查询avd

root@james:/home/james/cupcake-1.5.2# android list avd
Available Android Virtual Devices:
    Name: G1-sdk-15
    Path: /root/.android/avd/G1-sdk-15.avd
  Target: Google APIs (Google Inc.)
          Based on Android 1.5 (API level 3)
    Skin: HVGA


运行仿真

emulator -avd G1-sdk-15 -system /home/james/cupcake-1.5.2/out/target/product/generic/system.img -ramdisk /home/james/cupcake-1.5.2/out/target/product/generic/ramdisk.img -init-data /home/james/cupcake-1.5.2/out/target/product/generic/userdata.img -show-kernel