在Android2.2.1上编译Mokoid源码
参考 刘洪涛 Android HAL实例解析 http://blog.csdn.net/hongtao_liu/article/details/6060734
Android HAL实例学习 http://blog.csdn.net/pochuanpiao/article/details/6561170
具体步骤:
1、放置Mokoid工程源码到external目录
2、编译
出现问题及其解决方案,上面两个博客基本上涵盖了所以问题。
(1)启动后没有图标,找不到应用程序
目标系统启动后找不到两个应用程序的图标。仔细阅读logcat输出的信息发现:
E/PackageManager( 2717): Package com.mokoid.LedClient requires unavailable shared library com.mokoid.server; failing!
原因是找不到 com.mokoid.server。检查mokoid-read-only/frameworks/base/Android.mk发现系统将LedManager和LedService编译成 mokoid.jar库文件。为了让应用程序可以访问到这个库,需要通过com.mokoid.server.xml 来设定其对应关系。解决方法:拷贝com.mokoid.server.xml到目标系统的system/etc/permissions/目录下
此时两个应用的程序的图标都正常出现了。
(2) make: *** 没有规则可以创建“out/target/product/ut6410/obj/SHARED_LIBRARIES/led.goldfish_intermediates/led.goldfish.o”需要的目标“vendor/mokoid/hardware/mo看/mokoid/hardware/modules/led/Android.mk注释掉不要的--------------------------------------------------------------------------------------------------( 3)target thumb C++: libmokoid_runtime <= vendor/mokoid/frameworks/base/service/jni/onload.cpp
arm-eabi-g++: vendor/mokoid/frameworks/base/service/jni/onload.cpp: No such file or directory
arm-eabi-g++: no input files看vendor/mokoid/frameworks/base/service/jni/Android.mk文件。找不到onload.cpp,从google code下载下来就没有,先注释掉。
(4) 运行成程序,界面提示异常,用logcat看日志,提示找不到 JNI_OnLoad,把《Android HAL实例解析 - 刘洪涛的专栏》文中提到的第三点代码copy到com_mokoid_server_LedService.cpp中,重新编译
3、重新编译打包运行即可。下面是编译的信息。
--------------------------------------------------------------------------------------------------make:进入目录'/home/zhangfang/Android/source'
build/core/base_rules.mk:108: user tag on app LedClient at external/Mokoid/mokoid-read-only/apps/LedClient - add your app to core.mk instead
build/core/base_rules.mk:108: user tag on app LedTest at external/Mokoid/mokoid-read-only/apps/LedTest - add your app to core.mk instead
Copying: out/target/common/obj/JAVA_LIBRARIES/mokoid_intermediates/classes-full-debug.jar
Copying: out/target/common/obj/APPS/LedClient_intermediates/classes-full-debug.jar
Install: out/target/product/generic/system/app/LedClient.apk
Copying: out/target/common/obj/APPS/LedTest_intermediates/classes-full-debug.jar
Install: out/target/product/generic/system/app/LedTest.apk
Install: out/target/product/generic/system/framework/mokoid.jar
target thumb C++: libmokoid_runtime <= external/Mokoid/mokoid-read-only/frameworks/base/service/jni/com_mokoid_server_LedService.cpp
In file included from external/Mokoid/mokoid-read-only/frameworks/base/service/jni/com_mokoid_server_LedService.cpp:25:
dalvik/libnativehelper/include/nativehelper/jni.h:489: note: the mangling of 'va_list' has changed in GCC 4.4
target SharedLib: libmokoid_runtime (out/target/product/generic/obj/SHARED_LIBRARIES/libmokoid_runtime_intermediates/LINKED/libmokoid_runtime.so)
target Non-prelinked: libmokoid_runtime (out/target/product/generic/symbols/system/lib/libmokoid_runtime.so)
target Strip: libmokoid_runtime (out/target/product/generic/obj/lib/libmokoid_runtime.so)
Install: out/target/product/generic/system/lib/libmokoid_runtime.so
target Non-prelinked: libled (out/target/product/generic/symbols/system/lib/libled.so)
Install: out/target/product/generic/system/lib/libled.so
target Non-prelinked: led.default (out/target/product/generic/symbols/system/lib/led.default.so)
Install: out/target/product/generic/system/lib/hw/led.default.so
make:离开目录“/home/zhangfang/Android/source”