我正在尝试将Halo移植到Cyanogenmod 11.我的设备是xhdpi。 构建很顺利,它甚至可以启动,但是使用此日志导致systemui崩溃 - >
E/AndroidRuntime( 1875): FATAL EXCEPTION: main
E/AndroidRuntime( 1875): Process: com.android.systemui, PID: 1875
E/AndroidRuntime( 1875): java.lang.NullPointerException
E/AndroidRuntime( 1875): at com.android.systemui.statusbar.BaseStatusBar.updateHalo(BaseStatusBar.java:472)
E/AndroidRuntime( 1875): at com.android.systemui.statusbar.BaseStatusBar.start(BaseStatusBar.java:448)
E/AndroidRuntime( 1875): at com.android.systemui.statusbar.phone.PhoneStatusBar.start(PhoneStatusBar.java:562)
E/AndroidRuntime( 1875): at com.android.systemui.statusbar.SystemBars.createStatusBarFromConfig(SystemBars.java:106)
E/AndroidRuntime( 1875): at com.android.systemui.statusbar.SystemBars.onNoService(SystemBars.java:58)
E/AndroidRuntime( 1875): at com.android.systemui.statusbar.ServiceMonitor.startService(ServiceMonitor.java:228)
E/AndroidRuntime( 1875): at com.android.systemui.statusbar.ServiceMonitor.access$000(ServiceMonitor.java:49)
E/AndroidRuntime( 1875): at com.android.systemui.statusbar.ServiceMonitor$1.handleMessage(ServiceMonitor.java:73)
E/AndroidRuntime( 1875): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 1875): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 1875): at android.app.ActivityThread.main(ActivityThread.java:5153)
E/AndroidRuntime( 1875): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1875): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 1875): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
E/AndroidRuntime( 1875): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
E/AndroidRuntime( 1875): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 662): Process com.android.systemui has crashed too many times: killing!
在文件“BaseStatusBar.java”中,第472行引用了这部分代码:
protected void updateHalo() {
mHaloActive = Settings.System.getInt(mContext.getContentResolver(),
Settings.System.HALO_ACTIVE, 0) == 1;
//THE LINE BELOW IS LINE 472
mHaloButton.setImageResource(mHaloActive ? R.drawable.ic_notify_halo_pressed : R.drawable.ic_notify_halo_normal);
if (mHaloActive) {
if (mHalo == null) {
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mHalo = (Halo) inflater.inflate(R.layout.halo_trigger, null);
mHalo.setLayerType(View.LAYER_TYPE_HARDWARE, null);
WindowManager.LayoutParams params = mHalo.getWMParams();
mWindowManager.addView(mHalo, params);
mHalo.setStatusBar(this);
}
} else {
if (mHalo != null) {
mHalo.cleanUp();
mWindowManager.removeView(mHalo);
mHalo = null;
}
}
}
根据这一点,我认为资源(即图标)“ic_notify_halo_pressed”和“ic_notify_halo_normal”“应该出现在drawable-xhdpi文件夹中吗?是的,它们是。但它仍然会出错。
此外,ic_notify_halo.xml(在drawable文件夹中)具有以下内容 - >
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/ic_notify_halo_pressed" />
<item android:drawable="@drawable/ic_notify_halo_normal" />
</selector>
如果你想看看BaseStatusBar.java-&gt; http://pastebin.com/nTp2a0wX
我真的无法找到问题,请帮助。
另一件事,在编译/构建rom之前,编译器给了我这个错误 - &gt;
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java:1270: cannot find symbol
symbol : class Resources
location: class com.android.systemui.statusbar.BaseStatusBar
Resources res = mContext.getResources();
^
但是我通过添加导入行来修复它 - &gt; import android.content.res.Resources;
(这只是猜测,但编译器并没有给我任何错误)。我希望这与问题无关。