参照网上的移植过一次,有以下3个问题先需要注意:
一. 下载相应的android-x86版本代码,否则出错的几率很大
二. 如出现android.net.ethernet.ethernetstatetracker.cpp stripped of.....这一错误时,大多是版本不对
三. 编译完成后,如出现以下错误,按照代码修改即可:
主要从android-x86中移植过来,分成3部分。
1. build/core/pathmap.mk
FRAMEWORKS_BASE_SUBDIRS := \
$(addsuffix /java, \
sax \
telephony \
ethernet \
2. packages/apps/Settings/中增加及修改
参照android-x86中gingerbread-x86分支
3. frameworks/base/中增加及修改
参照android-x86中gingerbread-x86分支
出现的问题:
1.现象:
# I/ActivityManager( 633): Starting: Intent { act=android.intent.action.MAIN cmp=com.android.settings/.EthernetSettings } from pid 1065
W/ApplicationContext( 1065): Error getting service name:ethernet
D/AndroidRuntime( 1065): Shutting down VM
W/dalvikvm( 1065): threadid=1: thread exiting with uncaught exception (group=0x40015560)
I/EthernetManager( 1065): Init Ethernet Manager, service: null
E/AndroidRuntime( 1065): FATAL EXCEPTION: main
E/AndroidRuntime( 1065): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.settings/com.android.settings.EthernetSettings}: java.lang.NullPointerException
E/AndroidRuntime( 1065): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
E/AndroidRuntime( 1065): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 1065): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 1065): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 1065): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 1065): at android.os.Looper.loop(Looper.java:130)
通过在frameworks/base/services/java/com/android/server/ConnectivityService.java中的函数
private ConnectivityService(Context context) {
增加一些log信息,可以知道attributes有出现问题,并没有 public static final int TYPE_ETHERNET = 9; 这个被找到。 log如下:
D/ConnectivityService( 87): netType:4 , mRadio:0
D/ConnectivityService( 87): netType:5 , mRadio:0
D/ConnectivityService( 87): netType:3 , mRadio:0
D/ConnectivityService( 87): netType:2 , mRadio:0
D/ConnectivityService( 87): netType:1 , mRadio:1
V/ConnectivityService( 87): Starting Wifi Service.
I/WifiService( 87): WifiService starting up with Wi-Fi enabled
D/ConnectivityService( 87): netType:0 , mRadio:0
中明明有增加
- "ethernet,9,9,1"
为什么就没了呢? 其实是在device/samsung/smdkv210/overlay目录下被
overlay了。
device/samsung/smdkv210/overlay/frameworks/base/core/res/res/values/config.xml
- "wifi,1,1,1"
- "mobile,0,0,0"
- "mobile_mms,2,0,2"
- "mobile_supl,3,0,2"
- "mobile_dun,4,0,4"
- "mobile_hipri,5,0,3"
- "ethernet,9,9,1"
在这里增加ethernet行后,上面的错误信息就没了。
2. 加入ethernet导致启动过程出错,进不了桌面,log:
W/dalvikvm( 390): No implementation found for native Landroid/net/ethernet/EthernetNative;.initEthernetNative ()I
W/dalvikvm( 390): threadid=27: thread exiting with uncaught exception (group=0x40015560)
D/ConnectivityService( 390): netType:9 , mRadio:9
V/ConnectivityService( 390): Starting Ethernet Service.
D/ConnectivityService( 390): Starting Ethernet Service.
V/EthernetStateTracker( 390): Starts...
E/AndroidRuntime( 390): *** FATAL EXCEPTION IN SYSTEM PROCESS: ConnectivityThread
E/AndroidRuntime( 390): java.lang.UnsatisfiedLinkError: initEthernetNative
E/AndroidRuntime( 390): at android.net.ethernet.EthernetNative.initEthernetNative(Native Method)
E/AndroidRuntime( 390): at android.net.ethernet.EthernetStateTracker.(EthernetStateTracker.java:83)
E/AndroidRuntime( 390): at com.android.server.ConnectivityService.(ConnectivityService.java:413)
E/AndroidRuntime( 390): at com.android.server.ConnectivityService.(ConnectivityService.java:66)
E/AndroidRuntime( 390): at com.android.server.ConnectivityService$ConnectivityThread.run(ConnectivityService.java:230)
而在frameworks/base/core/jni/android_net_ethernet.cpp中明明是有
{"initEthernetNative", "()I",
(void *)android_net_ethernet_initEthernetNative},
jeff@translogic:~/android/adv-iputer/jeff-2.3.7_r1$ grep register_android_net_ethernet_EthernetManager frameworks/base/ -r --include=*.cpp
frameworks/base/core/jni/android_net_ethernet.cpp: int register_android_net_ethernet_EthernetManager(JNIEnv* env)
jeff@translogic:~/android/adv-iputer/jeff-2.3.7_r1$
而在android-x86的frameworks/base目录搜索:
jeff@translogic:~/android/adv-iputer/jeff-2.3.7_r1$ grep register_android_net_ethernet_EthernetManager /common/android-x86/base/ -r --include=*.cpp
/common/android-x86/base/core/jni/android_net_ethernet.cpp: int register_android_net_ethernet_EthernetManager(JNIEnv* env)
/common/android-x86/base/core/jni/AndroidRuntime.cpp:extern int register_android_net_ethernet_EthernetManager(JNIEnv* env);
/common/android-x86/base/core/jni/AndroidRuntime.cpp: REG_JNI(register_android_net_ethernet_EthernetManager),
jeff@translogic:~/android/adv-iputer/jeff-2.3.7_r1$
所以是在 frameworks/base/core/jni/AndroidRuntime.cpp 中缺少了注册jni。 增加后就可以正常启动了。
好了,移植开始
一、准备工具:curl和repo