已解决错误: 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object re

报这种错误,但是程序强制退出。

11-18 16:02:26.490: W/WindowManager(312): Token{420aaa08 ActivityRecord{41c5fef8 com.rk.jcz/.IndexActivity}} failed creating starting window

11-18 16:02:26.490: W/WindowManager(312): android.view.InflateException: Binary XML file line #34: Error inflating class

11-18 16:02:26.490: W/WindowManager(312): at android.view.LayoutInflater.createView(LayoutInflater.java:606)

11-18 16:02:26.490: W/WindowManager(312): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)

11-18 16:02:26.490: W/WindowManager(312): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)

11-18 16:02:26.490: W/WindowManager(312): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)

11-18 16:02:26.490: W/WindowManager(312): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)

11-18 16:02:26.490: W/WindowManager(312): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

11-18 16:02:26.490: W/WindowManager(312): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

11-18 16:02:26.490: W/WindowManager(312): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)

11-18 16:02:26.490: W/WindowManager(312): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2753)

11-18 16:02:26.490: W/WindowManager(312): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2813)

11-18 16:02:26.490: W/WindowManager(312): at com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1554)

11-18 16:02:26.490: W/WindowManager(312): at com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:1369)

11-18 16:02:26.490: W/WindowManager(312): at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:6677)

11-18 16:02:26.490: W/WindowManager(312): at android.os.Handler.dispatchMessage(Handler.java:99)

11-18 16:02:26.490: W/WindowManager(312): at android.os.Looper.loop(Looper.java:137)

11-18 16:02:26.490: W/WindowManager(312): at com.android.server.wm.WindowManagerService$WMThread.run(WindowManagerService.java:703)

11-18 16:02:26.490: W/WindowManager(312): Caused by: java.lang.reflect.InvocationTargetException

11-18 16:02:26.490: W/WindowManager(312): at java.lang.reflect.Constructor.constructNative(Native Method)

11-18 16:02:26.490: W/WindowManager(312): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)

11-18 16:02:26.490: W/WindowManager(312): at android.view.LayoutInflater.createView(LayoutInflater.java:586)

11-18 16:02:26.490: W/WindowManager(312): ... 15 more



解决方案:
AndroidManifest.xml 工程的这个文件中,如果
 
        android:name=".v3.JCZApp"
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/ThemeActivity" >
这部分,有指定了theme: ,我这里是   android:theme="@style/ThemeActivity" ,
然后查看详细的 @style/ThemeActivity 定义如下:
 
有的朋友点出了关键点:theme,就是主题定义,在这个style中,加上   parent="android:Theme" ,再运行,发现问题解决,改后的style如下:
 

你可能感兴趣的:(Android项目报错)