首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当我加载模拟器时,它崩溃了,并说“不幸的是'myapp‘停止工作了”。

当我加载模拟器时,它崩溃了,并说“不幸的是'myapp‘停止工作了”。
EN

Stack Overflow用户
提问于 2016-03-05 17:21:49
回答 2查看 74关注 0票数 1

我已经创建了一个页面,在我的应用程序上显示问题。我使用了滚动文本视图,当我加载模拟器时,会出现一条错误消息,说“不幸的是'myapp‘已经停止工作”。该页面已添加到清单中。提前谢谢你。

代码:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="katyloughrey5055.myapplication.QuestionsOnChapter7"
    tools:showIn="@layout/activity_questions_on_chapter7">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Questions On Chapter 7 Differentiaion"
        android:id="@+id/textView93"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />


    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Back"
        android:id="@+id/Back5"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_marginBottom="44dp" />

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView"
        android:layout_below="@+id/textView93"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignRight="@+id/textView93"
        android:layout_alignEnd="@+id/textView93"
        android:layout_above="@+id/Back5">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=" 1. A curve has equation : x² + 2xy – 3y² + 16 = 0. Find the coordinates of the points on the curve where dy/dx=0           2. A curve C is described by the equation :3x² + 4y² – 2x + 6xy – 5 = 0. Find an equation of the tangent to C at the point (1, –2).           3. A curve C is described by the equation 3x² – 2y² + 2x – 3y + 5 = 0. Find an equation of the normal to C at the point (0, 1).           4. A curve has parametric equations:x=7cost–cos7t, y= 7sint– sin7t, π/8&lt;t&lt;π/3.     (a) Find an expression for in terms of t. You need not simplify your answer.     (b) Find an equation of the normal to the curve at the point where t=π/6. Give your answer in its simplest exact form.           5. A set of curves is given by the equation sinx+cosy=0.5.     (a) Use implicit differentiation to find an expression for dy/dx     For -π&lt;x&lt;π -π&lt;y&lt;π     (b) find the coordinates of the points where dy/dx=0.           6. A curve is described by the equation x³-4y²=12xy           7. (a) Find the coordinates of the two points on the curve where x = –8.     (b) Find the gradient of the curve at each of these points.           8.A curve has equation 3x² – y² + xy = 4. The points P and Q lie on the curve. The gradient of the tangent to the curve is 83 at P and at Q .     (a) Use implicit differentiation to show that y – 2x = 0 at P and at Q.     (b) Find the coordinates of P and Q.          9.A curve C has the equation y² – 3y = x³ + 8.     (a) Find dy/dx in terms of x and y.     (b) Hence find the gradient of C at the point where y=3.         10.A curve is described by the equation x² + 4xy + y² + 27 = 0     (a) Find dy/dx in terms of x and y. A point Q lies on the curve. The tangent to the curve at Q is parallel to the y-axis.Given that the x coordinate of Q is negative, (b) use your answer to part (a) to find the coordinates of Q.&quot;"
            android:id="@+id/textView5" />
    </ScrollView>


</RelativeLayout>

LogCat:

代码语言:javascript
运行
复制
 03-05 08:36:23.098 1921-1935/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0xacbcc8d0
                03-05 08:36:23.185 243-269/? I/ActivityManager: Displayed katyloughrey5055.myapplication/.QuizOnChapter7: +1s221ms
                03-05 08:37:03.573 1921-1935/? W/EGL_emulation: eglSurfaceAttrib not implemented
                03-05 08:37:03.574 1921-1935/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa44f2280, error=EGL_SUCCESS
                03-05 08:37:03.781 1921-1935/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0xacbcc2b0
                03-05 08:37:05.765 243-548/? I/ActivityManager: START u0 {cmp=katyloughrey5055.myapplication/.QuestionsOnChapter7} from uid 10061 on display 0
                03-05 08:37:06.898 1921-1921/? D/AndroidRuntime: Shutting down VM
                03-05 08:37:06.907 1921-1921/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                         Process: katyloughrey5055.myapplication, PID: 1921
                                                         java.lang.RuntimeException: Unable to start activity ComponentInfo{katyloughrey5055.myapplication/katyloughrey5055.myapplication.QuestionsOnChapter7}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                             at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                             at android.os.Handler.dispatchMessage(Handler.java:102)
                                                             at android.os.Looper.loop(Looper.java:148)
                                                             at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                             at java.lang.reflect.Method.invoke(Native Method)
                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                          Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
                                                             at katyloughrey5055.myapplication.QuestionsOnChapter7.onCreate(QuestionsOnChapter7.java:19)
                                                             at android.app.Activity.performCreate(Activity.java:6237)
                                                             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                             at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                             at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                             at android.os.Looper.loop(Looper.java:148) 
                                                             at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                             at java.lang.reflect.Method.invoke(Native Method) 
                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
               03-05 08:37:06.935 243-354/? W/ActivityManager:   Force finishing activity katyloughrey5055.myapplication/.QuestionsOnChapter7
        03-05 08:37:07.041 243-354/? W/ActivityManager:   Force finishing activity katyloughrey5055.myapplication/.Chapter7
        03-05 08:37:07.097 243-261/? W/art: Long monitor contention event with owner method=void com.android.server.am.ActivityManagerService.crashApplication(com.android.server.am.ProcessRecord, android.app.ApplicationErrorReport$CrashInfo) from ActivityManagerService.java:12502 waiters=0 for 160ms
        03-05 08:37:07.404 243-709/? I/OpenGLRenderer: Initialized EGL, version 1.4
        03-05 08:37:07.434 243-709/? W/EGL_emulation: eglSurfaceAttrib not implemented
        03-05 08:37:07.434 243-709/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xa15b4060, error=EGL_SUCCESS
        03-05 08:37:07.542 243-261/? W/ActivityManager: Activity pause timeout for ActivityRecord{51ae1ae u0 katyloughrey5055.myapplication/.QuestionsOnChapter7 t550 f}
        03-05 08:37:15.843 243-261/? W/ActivityManager: Launch timeout has expired, giving up wake lock!
        03-05 08:37:17.097 243-261/? W/ActivityManager: Activity destroy timeout for ActivityRecord{4286281 u0 katyloughrey5055.myapplication/.Chapter7 t550 f}
        03-05 08:37:25.986 243-261/? W/ActivityManager: Activity destroy timeout for ActivityRecord{51ae1ae u0 katyloughrey5055.myapplication/.QuestionsOnChapter7 t550 f}
        03-05 08:38:02.063 1921-1921/? I/Process: Sending signal. PID: 1921 SIG: 9
        03-05 08:38:02.139 243-709/? E/Surface: getSlotFromBufferLocked: unknown buffer: 0xa0a93c90
        03-05 08:38:02.146 243-709/? D/OpenGLRenderer: endAllStagingAnimators on 0xa11f2c00 (RippleDrawable) with handle 0x9e2fec10
        03-05 08:38:02.249 243-715/? D/GraphicsStats: Buffer count: 3
        03-05 08:38:02.251 243-715/? I/WindowState: WIN DEATH: Window{31d21d1 u0 katyloughrey5055.myapplication/katyloughrey5055.myapplication.StudentPage}
        03-05 08:38:02.369 243-548/? I/ActivityManager: Process katyloughrey5055.myapplication (pid 1921) has died
        03-05 08:38:02.425 243-269/? W/AppOps: Finishing op nesting under-run: uid 1000 pkg android code 24 time=0 duration=0 nesting=0
        03-05 08:38:02.742 243-548/? I/ActivityManager: Start proc 2023:katyloughrey5055.myapplication/u0a61 for activity katyloughrey5055.myapplication/.StudentPage
        03-05 08:38:02.820 2023-2023/? I/art: Not late-enabling -Xcheck:jni (already on)
        03-05 08:38:02.821 2023-2023/? I/art: Late-enabling JIT
        03-05 08:38:02.973 2023-2023/? I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
        03-05 08:38:03.497 2023-2023/? W/System: ClassLoader referenced unknown path: /data/app/katyloughrey5055.myapplication-1/lib/arm
        03-05 08:38:04.120 59-275/? E/SurfaceFlinger: ro.sf.lcd_density must be defined as a build property
EN

回答 2

Stack Overflow用户

发布于 2016-03-05 17:25:02

您要么尝试获取具有错误id的Back5,然后分配一个OnClickListener,要么在从视图中获取按钮之前分配OnClickListener

票数 2
EN

Stack Overflow用户

发布于 2016-03-05 18:29:31

这是一个空指针异常,这意味着错误在你的java代码中。您正在使用错误的id获取Back5按钮,或者您可能在分配按钮id之前调用了单击侦听器方法。

代码语言:javascript
运行
复制
Button back=(Button)findVIewById(R.id.Back5);
back.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
        //your code
     }
  });
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35812350

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档