1. 启动模拟器
android源码目录下
. build/envsetup.sh
lunch 1
之后
emulator
即可启动模拟器
2. 命令行下看log
emulator起来后,用
adb logcat
即可看输出了,还可以加其他过滤选项
3. 命令行下安装应用
adb install ....apk
4. 命令行下进shell
adb shell
5. 模拟事件,发短信,打电话等
telnet localhos 5554
之后help看帮助
6. adb shell中看服务
service list
7. 新增一个系统应用
eclipse下的工程文件夹copy到packages/apps/目录下,增加Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += \
src/com/example/hellodroid/FullscreenActivity.java \
src/com/example/hellodroid/util/SystemUiHiderBase.java \
src/com/example/hellodroid/util/SystemUiHiderHoneycomb.java \
src/com/example/hellodroid/util/SystemUiHider.java
LOCAL_PACKAGE_NAME := HelloDroid
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
# Build the test package
include $(call all-makefiles-under,$(LOCAL_PATH))
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_SRC_FILES += \
src/com/example/hellodroid/FullscreenActivity.java \
src/com/example/hellodroid/util/SystemUiHiderBase.java \
src/com/example/hellodroid/util/SystemUiHiderHoneycomb.java \
src/com/example/hellodroid/util/SystemUiHider.java
LOCAL_PACKAGE_NAME := HelloDroid
LOCAL_CERTIFICATE := platform
include $(BUILD_PACKAGE)
# Build the test package
include $(call all-makefiles-under,$(LOCAL_PATH))
如果不想被打包安装到system/app下,
LOCAL_MODULE_TAGS := optional ----- LOCAL_MODULE_TAGS := tests
即可.
快速编译的方法是
HelloDroid目录下
mm
命令即可
8. 安装apk错误类型
Failure [INSTALL_FAILED_DEXOPT]
表示没找到DEX,这个一般是系统应用编译后,直接装apk造成的,解决办法是:安装未优化的包adb install out\target\product\generic\obj\APPS\HelloDroid_intermediates> package.apk.unaligned
Failure [INSTALL_FALIED_EXITS]
实际就是应用没变,删除 userdata.img即可
rm out/target/product/generic/userdata* -rf
Failure [INSTALL_FAILED_UID_CHANGED]
你以前安装过这个应用程序,到/data/data下删除完这个程序的包名对应的文件夹, 新安装的会另外生成uid。
装不上是因为检查到原来/data/data下的文件对应uid还是旧的
9. 编译目标可执行程序
Android.mk如下
#
# Copyright 2006 The Android Open Source Project
#
# Android Asset Packaging Tool
#
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
nsurface.cpp
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/http://www.cnblogs.com/include/ui \
${LOCAL_PATH}/http://www.cnblogs.com/include/utils \
${LOCAL_PATH}/http://www.cnblogs.com/include/gui \
external/skia/include/core \
external/skia/include/utils
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
libui \
libgui \
libskia
LOCAL_MODULE := nsurface
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
# Copyright 2006 The Android Open Source Project
#
# Android Asset Packaging Tool
#
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
nsurface.cpp
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/http://www.cnblogs.com/include/ui \
${LOCAL_PATH}/http://www.cnblogs.com/include/utils \
${LOCAL_PATH}/http://www.cnblogs.com/include/gui \
external/skia/include/core \
external/skia/include/utils
LOCAL_SHARED_LIBRARIES := \
libcutils \
libutils \
libui \
libgui \
libskia
LOCAL_MODULE := nsurface
LOCAL_MODULE_TAGS := optional
include $(BUILD_EXECUTABLE)
模块目录下 mm
10. 模拟器运行系统起不来
排除是修改错误之外,一般是userdata用户数据不一致了
删除userdata,重启模拟器即可
rm out/target/product/generic/userdata* -rf