I have a broadcast receiver that starts a service when a gcm message is received. But I get an exception saying :
Logs:
trace->java.lang.RuntimeException: Unable to start receiver         com.xyz.ab.gcm.GcmBroadcastReceiver: java.lang.ClassCastException:   com.xyz.ab.gcm.ServiceWrapperContext cannot be cast to  android.app.ContextImpl
 03-19 13:09:11.558: E/(8913): MainApplication: onCreate: uncaughtException:            
thread->mainException was: Unable to start receiver 
com.xyz.ab.gcm.GcmBroadcastReceiver: java.lang.ClassCastException:   
com.xyz.ab.ServiceWrapperContext cannot be cast to android.app.ContextImpl 
stack trace->java.lang.RuntimeException: Unable to start receiver 
com.xyz.ab.gcm.GcmBroadcastReceiver: java.lang.ClassCastException: 
com.xyz.ab.ServiceWrapperContext cannot be cast to android.app.ContextImpl
03-19 13:09:11.558: E/(8913):  at    
android.app.ActivityThread.handleReceiver(ActivityThread.java:2520)
03-19 13:09:11.558: E/(8913):  at 
android.app.ActivityThread.access$1500(ActivityThread.java:156)
03-19 13:09:11.558: E/(8913):  at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1416)
03-19 13:09:11.558: E/(8913):  at   
android.os.Handler.dispatchMessage(Handler.java:99) 
03-19 13:09:11.558: E/(8913):  at android.os.Looper.loop(Looper.java:153)
03-19 13:09:11.558: E/(8913):  at   
android.app.ActivityThread.main(ActivityThread.java:5297)
03-19 13:09:11.558: E/(8913):  at  
java.lang.reflect.Method.invokeNative(Native Method)
03-19 13:09:11.558: E/(8913):  at 
java.lang.reflect.Method.invoke(Method.java:511)
03-19 13:09:11.558: E/(8913):  at 
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833) 
03-19 13:09:11.558: E/(8913):  at  
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
03-19 13:09:11.558: E/(8913):  at dalvik.system.NativeStart.main(Native 
Method)
03-19 13:09:11.558: E/(8913): Caused by: java.lang.ClassCastException:  
com.xyz.ab.ServiceWrapperContext cannot be cast to android.app.ContextImpl
03-19 13:09:11.558: E/(8913):  at      
android.app.ActivityThread.handleReceiver(ActivityThread.java:2501)
Code causing issue:
 protected void attachBaseContext( Context base ) {
 ServiceWrapperContext context = new ServiceWrapperContext( base );
 context.addCallback( Context.LAYOUT_INFLATER_SERVICE,
            new TypefaceLayoutInflater.ServiceCallback( ) );
    super.attachBaseContext( context );
The ServiceWrapperContext extends ContextWrapper.
When I comment the above method it works fine else gives the above exception.
Please help as my colleague had made these changes. I tried few things but its not working. Not able to understand the issue here.