BOOTCLASSPATH 不添加jar包路径,系统启动后将无法找到自定义JAVA层系统服务的相关类,这是由于自定义系统服务jar包是Dalvik所需的基本库文件。如果不添加相关路径会报如下错误:

W/dalvikvm( 2582): Unable to resolve superclass of Lcom/android/server/yourdir/yourService; (1633)
W/dalvikvm( 2582): Link of class 'Lcom/android/server/yourdir/yourService;' failed
D/dalvikvm( 2582): DexOpt: unable to opt direct call 0x276b at 0x258 in Lcom/android/server/ServerThread;.run

三篇必看原理文章:

Android 类实现探索-系统基础类

Dalvik 分析之准备篇

Dalvik 分析 - Class加载篇


init.rc:
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/core-junit.jar
BOOTCLASSPATH=/ango/system/framework/core.jar:/ango/system/framework/bouncycastle.jar:/ango/system/framework/ext.jar:/ango/system/framework/framework.jar:/ango/system/framework/android.policy.jar:/ango/system/framework/services.jar:/ango/system/framework/core-junit.jar

d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/Init.c
//getenv of classpath and BOOTCLASSPATH configed by init.rc
static void setCommandLineDefaults()
putenv("BOOTCLASSPATH=/ango/system/framework/core.jar:/ango/system/framework/bouncycastle.jar:/ango/system/framework/ext.jar:/ango/system/framework/framework.jar:/ango/system/framework/android.policy.jar:/ango/system/framework/services.jar:/ango/system/framework/core-junit.jar");
envStr = getenv("BOOTCLASSPATH");
if (envStr != NULL)
gDvm.bootClassPathStr = strdup(envStr);
else
gDvm.bootClassPathStr = strdup(".");


d:/linux/linuxkernel/WORKING_DIRECTORY/android-omap-20111108-gingerbread/dalvik/vm/oo/Class.c
/*
* Prepare a ClassPathEntry struct, which at this point only has a valid
* filename. We need to figure out what kind of file it is, and for
* everything other than directories we need to open it up and see
* what's inside.
*/
static bool prepareCpe(ClassPathEntry* cpe, bool isBootstrap)
/*
* Convert a colon-separated list of directories, Zip files, and DEX files
* into an array of ClassPathEntry structs.
*
* During normal startup we fail if there are no entries, because we won't
* get very far without the basic language support classes, but if we're
* optimizing a DEX file we allow it.
*
* If entries are added or removed from the bootstrap class path, the
* dependencies in the DEX files will break, and everything except the
* very first entry will need to be regenerated.
*/
static ClassPathEntry* processClassPath(const char* pathStr, bool isBootstrap)
/*
* Initialize the bootstrap class loader.
*
* Call this after the bootclasspath string has been finalized.
*/
bool dvmClassStartup(void)

更多相关文章

  1. Android(安卓)Activity被回收后的处理
  2. Android(安卓)ApiDemos示例解析(18):App->Activity->Wallpaper
  3. 使用系统key文件生成keystore
  4. 关于android获得图片的总结
  5. Android6.0系统增加那些新特性
  6. 【Android(安卓)NDK 开发】Android(安卓)Studio 使用 CMake 导入
  7. 搭建Android生产环境傻瓜教程(一)Ubuntu系统环境和常用软件
  8. System Permissions --1.4
  9. Android(安卓)系统(102)---Android(安卓)APP耗电优化

随机推荐

  1. Android解析HTML+android爬虫框架jsoup
  2. Android各种屏幕的分布率以及自适应各种
  3. Android(安卓)Binder-涉及到Linux kernel
  4. Android(安卓)渐变 -- Shader
  5. Android(安卓)Fragment 详细翻译
  6. Android(安卓)中的MVP模式
  7. 五大手机操作系统
  8. Android自定义ViewPager(一)——自定义Scro
  9. Android(安卓)ImageLoader(Android-Univer
  10. Android(安卓)studio 安装 环境搭建