ubuntu 运行android模拟器(emulator)零星笔记、心得



android 2.3.3
export ANDROID_PRODUCT_OUT=/home/android_source/android-2.3.3_r1/out/target/product/generic
export PATH=$PATH:/home/android_source/android-2.3.3_r1/out/host/linux-x86/bin
emulator
adb shell


android 4.2
export ANDROID_PRODUCT_OUT=/home/android_source/android-4.2_r1/out/target/product/generic
export PATH=$PATH:/home/android_source/android-4.2_r1/out/host/linux-x86/bin
emulator



///export ANDROID_SWT=/home/android_source/android-4.2_r1/out/host/linux-x86/framework


emulator -system system.img -data userdata.img -ramdisk ramdisk.img

android create avd -n myemulator -f -p /home/android_source/android-4.2_r1 -t 1



make kernal
export PATH=$PATH:/home/android_source/android-4.2_r1/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin

#make goldfish_defconfig  会造成不能启动模拟器的情况

make goldfish_armv7_defconfig

make

编译结果:

then arch/arm/boot/zImage  is created


编译环境的安装:
http://blog.csdn.net/yf210yf/article/details/9206269


源码的编译:

source build/envsetup.sh
lunch full-eng
make


运行模拟器
在终端中执行:emulator


在  ~/.bashrc
添加环境变量:
export ANDROID_PRODUCT_OUT=~/code/android-4.2/out/target/product/generic
export ANDROID_SWT=~/code/android-4.2/out/host/linux-x86/framework/


备注:

重启系统后:
执行emulator,出现如下错误:
emulator: ERROR: You did not specify a virtual device name, and the system
directory could not be found.
If you are an Android SDK user, please use '@' or '-avd '
to start a given virtual device (see -help-avd for details).
Otherwise, follow the instructions in -help-disk-images to start the emulator

解决:
source build/envsetup.sh 
lunch sdk-eng

然后再执行
emulator
可以启动模拟器



emulator: WARNING: system partition size adjusted to match image file (216 MB > 200 MB)
解决:   emulator -partition-size 300


我按你所描述的步骤编译了goldfish2.6.29,生成了zImage,emulator -kernel xxxx/zImage 后可以启动模拟器,但是看不到Android画面,一直是黑乎乎的。    自己发现了原因:原来要$ make goldfish_armv7_defconfig



模拟器运行需要四个文件,分别是Linux Kernel镜像zImage和Android镜像文件system.img、userdata.img和ramdisk.img。执行emulator命令时,如果不带任何参数,则Linux Kernel镜像默认使用~/Android/prebuilt/android-arm/kernel目录下的kernel-qemu文件,而Android镜像文件则默认使用ANDROID_PRODUCT_OUT目录下的system.img、userdata.img和ramdisk.img,也就是我们刚刚编译出来的镜像问题。
    当然,我们也可以以指定的镜像文件来运行模拟器,即运行emulator时,即:

    USER-NAME@MACHINE-NAME:~/Android$ emulator -kernel ./prebuilt/android-arm/kernel/kernel-qemu -sysdir ./out/target/product/generic -system system.img -data userdata.img -ramdisk ramdisk.img






资源描述:

 frameworks/base/libs/utils/RefBase.cpp: In member function 'void android::RefBase::weakref_type::trackMe(bool, bool)':
frameworks/base/libs/utils/RefBase.cpp:507:67: error: passing 'const android::RefBase::weakref_impl' as 'this' argument of 'void android::RefBase::weakref_impl::trackMe(bool, bool)' discards qualifiers [-fpermissive]
解决办法:
编辑frameworks/base/libs/utils/Android.mk文件,修改
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) –fpermissive


修改之后出现错误:

   g++: 错误: –fpermissive:没有那个文件或目录




Ubuntu 11.04升级到12.04 后发现编译Android出现错误(之前是OK的),具体错误和解决办法如下:

问题1:

frameworks/base/libs/utils/RefBase.cpp: 在成员函数‘void android::RefBase::weakref_type::trackMe(bool, bool)’中:

frameworks/base/libs/utils/RefBase.cpp:483:67: 错误: 将‘const android::RefBase::weakref_impl’作为‘void android::RefBase::weakref_impl::trackMe(bool, bool)’的‘this’实参时丢弃了类型限定 [-fpermissive]

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1

原因:Ubuntu 11.10的gcc 4.6版本太高了,android编译需要gcc 4.4

解决办法:更换gcc、g++版本4.6为4.4

sudo apt-get install gcc-4.4

sudo apt-get install g++-4.4

sudo rm -rf /usr/bin/gcc /usr/bin/g++

sudo ln -s /usr/bin/gcc-4.4 /usr/bin/gcc

sudo ln -s /usr/bin/g++-4.4 /usr/bin/g++

问题2:

g++: 错误: –fpermissive:没有那个文件或目录

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/libutils_intermediates/RefBase.o] 错误 1

解决办法:sudo apt-get install g++-4.4-multilib

经过此操作编译可顺利进行。



你可能感兴趣的:(android)