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返回键的退出功能
  2. 2011.09.13(3)——— android 添加快捷方式并且图标上添加数字
  3. 自动批改android模拟器的imei的小程序 和 下载各个版本SDK Tools
  4. 去掉所有Activity界面标题栏、强制横屏竖屏
  5. Android内部存储和外部存储的获取方法
  6. android 完美退出所有Activity的demo
  7. APK安装路径移动至外部存储设备
  8. Android(安卓)MediaPlayer播放prepareAsync called in state 8解
  9. android实现图片按任意路径截取

随机推荐

  1. Android(安卓)自定义添加联系人
  2. android 滚动的缓冲图片
  3. android系统时间显示计时00:00:00
  4. android ---- ImageUtil工具类
  5. Android(安卓)build System
  6. android中添加级联更新的下拉菜单
  7. Android放大镜的实现
  8. Android(安卓)Wifi的一些属性
  9. html5写链接打开ios
  10. android项目迁移到androidX:类映射(android