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. Pycharm安装PyQt5的详细教程
  2. Android(安卓)Activity界面切换添加动画特效
  3. "Failed to fetch URL https://dl-ssl.google.com/android/repos
  4. Android(安卓)流式布局FlowLayout(搜索历史),多布局、删除、添加
  5. Android--SoLoader,android动态加载so库
  6. Android(安卓)命令行编译、打包生成apk文件
  7. Android(安卓)SDK Manager无法更新的解决
  8. Android(安卓)Activity界面切换添加动画特效
  9. [APP] Android(安卓)开发笔记 006-使用短信验证SDK进行短信验证

随机推荐

  1. 【代码】利用Android的Log 演示一个activ
  2. android 下动态获取控件的id
  3. android 監聽系統屬性變化的方法
  4. Android LCD
  5. Android:调用系统分享功能
  6. zz Android HTML5 video play
  7. android notification 的例子
  8. NDK调试
  9. android 获得当前活动的Acticity
  10. Android打造带删除的EditText并且实现输