重新启动应用程序时的运行时和nullpointer异常

时间:2013-04-04 09:39:27

标签: java android nullpointerexception

该应用程序工作正常,但有问题,当我销毁应用程序。 这是我的错误日志。

04-04 12:32:40.529: E/AndroidRuntime(6290): FATAL EXCEPTION: main
04-04 12:32:40.529: E/AndroidRuntime(6290): java.lang.RuntimeException: Unable to instantiate application android.app.Application: java.lang.NullPointerException
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.app.LoadedApk.makeApplication(LoadedApk.java:482)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3955)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.app.ActivityThread.access$1300(ActivityThread.java:127)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.os.Looper.loop(Looper.java:137)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.app.ActivityThread.main(ActivityThread.java:4441)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at java.lang.reflect.Method.invokeNative(Native Method)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at java.lang.reflect.Method.invoke(Method.java:511)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at dalvik.system.NativeStart.main(Native Method)
04-04 12:32:40.529: E/AndroidRuntime(6290): Caused by: java.lang.NullPointerException
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.app.LoadedApk.initializeJavaContextClassLoader(LoadedApk.java:362)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.app.LoadedApk.getClassLoader(LoadedApk.java:305)
04-04 12:32:40.529: E/AndroidRuntime(6290):     at android.app.LoadedApk.makeApplication(LoadedApk.java:474)
04-04 12:32:40.529: E/AndroidRuntime(6290):     ... 11 more

我发现导致它的视图,但我不明白为什么以及如何在将来避免它。

这是我在布局文件中的视图,并在代码中初始化它:

<LinearLayout
                android:id="@+id/terms_button_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/dp10"
                android:background="@drawable/car_component_border"
                android:padding="@dimen/cell_padding_top" >

                <ImageView
                    android:id="@+id/terms_image"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/terms" />

                <TextView
                    android:id="@+id/terms_text"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="@string/terms_of_use"
                    android:textAppearance="?android:attr/textAppearanceLarge" />
            </LinearLayout>


terms = (LinearLayout) findViewById(R.id.terms_button_layout);

我做错了什么?

0 个答案:

没有答案