问题
I am trying to build the Settings.apk to be used on Glass from the Hacking Glass session at Google I/O here: https://www.youtube.com/watch?feature=player_detailpage&v=OPethpwuYEk#t=500s
He mentions that in order for settings apk to work one line in the manifest needs to be modified. This is the AOSP manifest as it is:
http://pastebin.com/2yQ3QEgX (Added to pastebin due to length)
Every time I run the settings app, it crashes out and this is the logcat output:
I/PowerManagerService( 184): Auto-brightness: light sensor = 320, brightness = 255
D/Watchdog( 683): Checking for errors
D/dalvikvm( 683): GC_CONCURRENT freed 363K, 43% free 9944K/17223K, paused 3ms+2ms
D/dalvikvm( 683): GC_CONCURRENT freed 382K, 42% free 10074K/17223K, paused 3ms+1ms
D/dalvikvm( 683): GC_CONCURRENT freed 363K, 41% free 10191K/17223K, paused 2ms+2ms
D/dalvikvm( 683): GC_CONCURRENT freed 529K, 42% free 10147K/17223K, paused 4ms+2ms
I/ActivityManager( 184): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cm
p=com.android.settings/.Settings} from pid 4506
D/dalvikvm( 683): GC_CONCURRENT freed 323K, 41% free 10244K/17223K, paused 2ms+2ms
D/dalvikvm( 683): GC_FOR_ALLOC freed 229K, 41% free 10314K/17223K, paused 60ms
I/ActivityManager( 184): Start proc com.android.settings for activity com.android.settings/.Settings: pid=4998 uid=1003
0 gids={1015, 3002, 3001, 3003}
D/OpenGLRenderer( 471): Flushing caches (mode 1)
D/OpenGLRenderer( 4506): Flushing caches (mode 1)
D/OpenGLRenderer( 4506): Flushing caches (mode 0)
W/System.err( 4998): Removed 2131231170
W/System.err( 4998): Removed 2131231177
W/InputManagerService( 184): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Pro
xy@418cfb28 (uid=10029 pid=4506)
D/dalvikvm( 683): GC_CONCURRENT freed 342K, 40% free 10419K/17223K, paused 63ms+3ms
D/LocalBluetoothProfileManager( 4998): LocalBluetoothProfileManager construction complete
D/dalvikvm( 4998): GC_CONCURRENT freed 136K, 3% free 9364K/9607K, paused 2ms+2ms
D/dalvikvm( 683): GC_FOR_ALLOC freed 354K, 39% free 10576K/17223K, paused 23ms
D/libEGL ( 4998): loaded /system/lib/egl/libGLES_android.so
D/libEGL ( 4998): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
D/libEGL ( 4998): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
D/libEGL ( 4998): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
D/dalvikvm( 683): GC_CONCURRENT freed 121K, 39% free 10615K/17223K, paused 2ms+4ms
D/dalvikvm( 683): GC_FOR_ALLOC freed 38K, 39% free 10576K/17223K, paused 37ms
I/dalvikvm-heap( 683): Grow heap (frag case) to 11.089MB for 725488-byte allocation
D/OpenGLRenderer( 4998): Enabling debug mode 0
D/BluetoothAdapterStateMachine( 184): BluetoothOn process message: 1
W/BluetoothAdapterStateMachine( 184): BluetoothOn received: 1
D/AndroidRuntime( 4998): Shutting down VM
W/dalvikvm( 4998): threadid=1: thread exiting with uncaught exception (group=0x40d821f8)
D/dalvikvm( 683): GC_FOR_ALLOC freed 472K, 38% free 10812K/17223K, paused 51ms
E/AndroidRuntime( 4998): FATAL EXCEPTION: main
E/AndroidRuntime( 4998): java.lang.NullPointerException
E/AndroidRuntime( 4998): at com.android.settings.Settings$HeaderAdapter.getView(Settings.java:515)
E/AndroidRuntime( 4998): at android.widget.AbsListView.obtainView(AbsListView.java:2033)
E/AndroidRuntime( 4998): at android.widget.ListView.makeAndAddView(ListView.java:1772)
E/AndroidRuntime( 4998): at android.widget.ListView.fillDown(ListView.java:672)
E/AndroidRuntime( 4998): at android.widget.ListView.fillFromTop(ListView.java:732)
E/AndroidRuntime( 4998): at android.widget.ListView.layoutChildren(ListView.java:1625)
E/AndroidRuntime( 4998): at android.widget.AbsListView.onLayout(AbsListView.java:1863)
E/AndroidRuntime( 4998): at android.view.View.layout(View.java:11279)
E/AndroidRuntime( 4998): at android.view.ViewGroup.layout(ViewGroup.java:4224)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
E/AndroidRuntime( 4998): at android.view.View.layout(View.java:11279)
E/AndroidRuntime( 4998): at android.view.ViewGroup.layout(ViewGroup.java:4224)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1617)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.onLayout(LinearLayout.java:1401)
E/AndroidRuntime( 4998): at android.view.View.layout(View.java:11279)
E/AndroidRuntime( 4998): at android.view.ViewGroup.layout(ViewGroup.java:4224)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
E/AndroidRuntime( 4998): at android.view.View.layout(View.java:11279)
E/AndroidRuntime( 4998): at android.view.ViewGroup.layout(ViewGroup.java:4224)
E/AndroidRuntime( 4998): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
E/AndroidRuntime( 4998): at android.view.View.layout(View.java:11279)
E/AndroidRuntime( 4998): at android.view.ViewGroup.layout(ViewGroup.java:4224)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1628)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1486)
E/AndroidRuntime( 4998): at android.widget.LinearLayout.onLayout(LinearLayout.java:1399)
E/AndroidRuntime( 4998): at android.view.View.layout(View.java:11279)
E/AndroidRuntime( 4998): at android.view.ViewGroup.layout(ViewGroup.java:4224)
E/AndroidRuntime( 4998): at android.widget.FrameLayout.onLayout(FrameLayout.java:431)
E/AndroidRuntime( 4998): at android.view.View.layout(View.java:11279)
E/AndroidRuntime( 4998): at android.view.ViewGroup.layout(ViewGroup.java:4224)
E/AndroidRuntime( 4998): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1498)
E/AndroidRuntime( 4998): at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2451)
E/AndroidRuntime( 4998): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4998): at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 4998): at android.app.ActivityThread.main(ActivityThread.java:4424)
E/AndroidRuntime( 4998): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4998): at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 4998): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
E/AndroidRuntime( 4998): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
E/AndroidRuntime( 4998): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 184): Force finishing activity com.android.settings/.Settings
W/ActivityManager( 184): Force finishing activity com.android.launcher/com.android.launcher2.Launcher
D/dalvikvm( 683): GC_FOR_ALLOC freed 317K, 38% free 10812K/17223K, paused 35ms
I/dalvikvm-heap( 683): Grow heap (frag case) to 11.666MB for 1088228-byte allocation
D/dalvikvm( 683): GC_CONCURRENT freed 0K, 32% free 11875K/17223K, paused 3ms+3ms
D/dalvikvm( 683): GC_FOR_ALLOC freed 1185K, 36% free 11167K/17223K, paused 29ms
I/dalvikvm-heap( 683): Grow heap (frag case) to 12.530MB for 1632338-byte allocation
D/dalvikvm( 683): GC_CONCURRENT freed 1062K, 33% free 11698K/17223K, paused 2ms+2ms
D/dalvikvm( 683): GC_FOR_ALLOC freed 179K, 33% free 11698K/17223K, paused 23ms
I/dalvikvm-heap( 683): Grow heap (frag case) to 12.666MB for 1229980-byte allocation
D/dalvikvm( 683): GC_CONCURRENT freed 0K, 26% free 12899K/17223K, paused 2ms+2ms
W/ActivityManager( 184): Activity pause timeout for ActivityRecord{416eb7f8 com.android.settings/.Settings}
V/MainTimelineActivity( 471): onStart: 416dc890
D/MainTimelineActivity( 471): Already in guest mode state: false
V/MainTimelineActivity( 471): onResume: 416dc890
D/InputDetector( 471): Binding voice service
D/SafeBroadcastReceiver( 471): Registered receiver 'MainTimelineActivity/longPressInterceptor'.
D/BaseHorizontalScrollView( 471): Activating.
D/ActiveItemAdapter( 471): Activating adapter.
D/OngoingActivityService( 471): Added listener ActiveItemAdapter, count=1
D/SafeBroadcastReceiver( 471): Registered receiver 'SettingsCoverView/stateReceiver'.
W/SafeBroadcastReceiver( 471): Not registering receiver 'InetConnectionState/connectivityReceiver', because it is alrea
dy registered.
D/SafeBroadcastReceiver( 471): Registered receiver 'BluetoothTetheringState/stateChangeReceiver'.
V/BatteryHelper( 471): Current battery percent: 94.0
I/BatteryHelper( 471): Driver is not reporting charged, checking percent.
V/BatteryHelper( 471): Current battery percent: 94.0
V/BatteryHelper( 471): Battery is charged? false
V/BatteryHelper( 471): Battery currently charging? true
V/BatteryHelper( 471): Battery currently charging? true
I/BatteryHelper( 471): Driver is not reporting charged, checking percent.
V/BatteryHelper( 471): Current battery percent: 94.0
V/BatteryHelper( 471): Battery is charged? false
W/InputDetector( 471): Trying to change VoiceConfig before connection to VoiceService established
D/MainTimelineView( 471): Updating cursor select args: [1371680604322]
D/MainTimelineView( 471): Updating cursor select args: [1369088614323]
D/MainTimelineActivity( 471): There is no pending task, checking for pending runnable.
D/MainTimelineActivity( 471): No pending intent, showing the timeline.
W/MainTimelineActivity( 471): No wake up time known.
D/MainTimelineActivity( 471): Setting isFromScreenOffNotification: false
D/InputDetector( 471): Voice service connected
V/BatteryHelper( 471): Current battery percent: 94.0
I/BatteryHelper( 471): Driver is not reporting charged, checking percent.
V/BatteryHelper( 471): Current battery percent: 94.0
V/BatteryHelper( 471): Battery is charged? false
V/BatteryHelper( 471): Battery currently charging? true
V/BatteryHelper( 471): Battery currently charging? true
I/BatteryHelper( 471): Driver is not reporting charged, checking percent.
V/BatteryHelper( 471): Current battery percent: 94.0
V/BatteryHelper( 471): Battery is charged? false
D/UserEventHelper( 471): Logging user event [action=UI_THREAD_QUEUE, data=|a=11.000|v=98.000|].
D/UserEventHelper( 471): Logging user event [action=UI_TIME_TO_RENDER, data=|a=0.707|v=0.962|].
D/UserEventHelper( 471): Logging user event [action=UI_TIME_BETWEEN_RENDERS, data=|a=20.974|v=164.447|].
D/MainTimelineActivity( 471): Voice Service Connected
D/MainTimelineActivity( 471): getting config from timelineView
D/VoiceService( 471): setConfig called with VoiceConfig:OFF
D/TimelineCursorManager( 471): Received updated cursor: 160
D/MainTimelineView( 471): New timeline database content loaded; updating views.
D/TimelineCursorManager( 471): Received updated cursor: 160
D/MainTimelineView( 471): New timeline database content loaded; updating views.
V/BatteryHelper( 471): Current battery percent: 94.0
I/BatteryHelper( 471): Driver is not reporting charged, checking percent.
V/BatteryHelper( 471): Current battery percent: 94.0
V/BatteryHelper( 471): Battery is charged? false
V/BatteryHelper( 471): Battery currently charging? true
V/BatteryHelper( 471): Battery currently charging? true
I/BatteryHelper( 471): Driver is not reporting charged, checking percent.
V/BatteryHelper( 471): Current battery percent: 94.0
V/BatteryHelper( 471): Battery is charged? false
D/dalvikvm( 471): GC_CONCURRENT freed 2947K, 21% free 27249K/34183K, paused 4ms+23ms
V/BatteryHelper( 683): Battery currently charging? true
I/BatteryHelper( 683): Driver is not reporting charged, checking percent.
V/BatteryHelper( 683): Current battery percent: 94.0
V/BatteryHelper( 683): Battery is charged? false
V/BatteryHelper( 683): Battery currently charging? true
I/BatteryHelper( 683): Driver is not reporting charged, checking percent.
V/BatteryHelper( 683): Current battery percent: 94.0
V/BatteryHelper( 683): Battery is charged? false
V/BatteryHelper( 683): Battery currently charging? true
I/BatteryHelper( 683): Driver is not reporting charged, checking percent.
V/BatteryHelper( 683): Current battery percent: 94.0
V/BatteryHelper( 683): Battery is charged? false
I/PowerManagerService( 184): Auto-brightness: light sensor = 239, brightness = 255
Any thoughts on what should be modified in the manifest in order to get this working?
回答1:
for the Settings apk from ICS MR1 branch, in addition to removing the sharedUserId field in the AndroidManifest...
the crash your seeing is because icon and summary fields of the holder are null. com.android.internal.R.layout.preference_header_item is a simple TextView.
if you swap in R.layout.preference_header_switch_item, and hide the switch it should work.
@@ -480,9 +481,10 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler {
case HEADER_TYPE_NORMAL:
view = mInflater.inflate(
- com.android.internal.R.layout.preference_header_item, parent,
+ R.layout.preference_header_switch_item, parent,
false);
- holder.icon = (ImageView) view.findViewById(com.android.internal.R.id.icon);
+ view.findViewById(R.id.switchWidget).setVisibility(View.GONE);
+ holder.icon = (ImageView) view.findViewById(R.id.icon);
holder.title = (TextView)
view.findViewById(com.android.internal.R.id.title);
holder.summary = (TextView)
回答2:
android:sharedUserId="android.uid.system" This line should be deleted if you compiled Settings apk from ICS MR1 branch.
来源:https://stackoverflow.com/questions/16659552/modify-settings-apk-to-work-with-project-glass