gpt4 book ai didi

Android 应用程序错误 “Unfortunately App has Stopped” - 编程新手

转载 作者:太空狗 更新时间:2023-10-29 15:07:47 27 4
gpt4 key购买 nike

由于我是编程新手,我很难在我的代码中找到问题。我将不胜感激你的帮助。我知道我得到了 NullPointerException 但我找不到解决方案:

....

非常感谢大家!我改变了它。但它仍然给我这个(*注意我试图添加声音。但即使我排除了 MediaPlayer,它也不起作用):

11-26 08:41:30.356: I/ActivityManager(371): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.thenewboston.christoph/.Splash} from pid 531
11-26 08:41:30.486: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.486: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.496: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.496: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.506: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.506: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.506: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.506: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.506: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.506: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:30.506: E/SoundPool(371): error loading /system/media/audio/ui/KeypressStandard.ogg
11-26 08:41:30.506: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
11-26 08:41:30.506: E/SoundPool(371): error loading /system/media/audio/ui/KeypressSpacebar.ogg
11-26 08:41:30.506: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
11-26 08:41:30.506: E/SoundPool(371): error loading /system/media/audio/ui/KeypressDelete.ogg
11-26 08:41:30.516: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
11-26 08:41:30.516: E/SoundPool(371): error loading /system/media/audio/ui/KeypressReturn.ogg
11-26 08:41:30.516: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
11-26 08:41:30.516: E/SoundPool(371): error loading /system/media/audio/ui/KeypressInvalid.ogg
11-26 08:41:30.516: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
11-26 08:41:30.516: W/AudioService(371): onLoadSoundEffects(), Error -1 while loading samples
11-26 08:41:30.586: D/gralloc(52): Registering a buffer in the process that created it. This may cause memory ordering problems.
11-26 08:41:30.586: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:30.596: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:30.596: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:30.596: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:30.596: E/SurfaceFlinger(52): glCheckFramebufferStatusOES error 552518609
11-26 08:41:30.596: E/SurfaceFlinger(52): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
11-26 08:41:30.596: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:30.596: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:30.596: W/WindowManager(371): Screenshot failure taking screenshot for (328x583) to layer 21005
11-26 08:41:30.626: I/Choreographer(531): Skipped 33 frames! The application may be doing too much work on its main thread.
11-26 08:41:30.886: I/Choreographer(371): Skipped 36 frames! The application may be doing too much work on its main thread.
11-26 08:41:31.196: W/ActivityManager(371): Activity pause timeout for ActivityRecord{b1fee0f8 u0 com.android.launcher/com.android.launcher2.Launcher t1}
11-26 08:41:31.406: I/ActivityManager(371): Start proc com.thenewboston.christoph for activity com.thenewboston.christoph/.Splash: pid=2391 uid=10051 gids={50051}
11-26 08:41:31.436: D/dalvikvm(2391): Not late-enabling CheckJNI (already on)
11-26 08:41:32.956: I/Choreographer(371): Skipped 32 frames! The application may be doing too much work on its main thread.
11-26 08:41:33.746: D/LightsService(371): Excessive delay setting light: 3798ms
11-26 08:41:33.996: D/dalvikvm(2391): GC_FOR_ALLOC freed 43K, 4% free 3033K/3148K, paused 58ms, total 60ms
11-26 08:41:34.026: I/dalvikvm-heap(2391): Grow heap (frag case) to 4.978MB for 2049424-byte allocation
11-26 08:41:34.216: D/dalvikvm(2391): GC_FOR_ALLOC freed 2K, 3% free 5031K/5152K, paused 183ms, total 183ms
11-26 08:41:35.016: D/gralloc_goldfish(2391): Emulator without GPU emulation detected.
11-26 08:41:35.426: I/ActivityManager(371): Displayed com.thenewboston.christoph/.Splash: +4s121ms (total +2m18s290ms)
11-26 08:41:39.536: I/ActivityManager(371): START u0 {act=com.thenewboston.christoph.STARTINGPOINT cmp=com.thenewboston.christoph/.StartingPoint} from pid 2391
11-26 08:41:39.566: D/gralloc(52): Registering a buffer in the process that created it. This may cause memory ordering problems.
11-26 08:41:39.566: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:39.566: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:39.566: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:39.576: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:39.576: E/SurfaceFlinger(52): glCheckFramebufferStatusOES error 552518609
11-26 08:41:39.576: E/SurfaceFlinger(52): got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot
11-26 08:41:39.576: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:39.576: E/libEGL(52): called unimplemented OpenGL ES API
11-26 08:41:39.576: W/WindowManager(371): Screenshot failure taking screenshot for (328x583) to layer 21010
11-26 08:41:39.706: D/AndroidRuntime(2391): Shutting down VM
11-26 08:41:39.706: W/dalvikvm(2391): threadid=1: thread exiting with uncaught exception (group=0xb1adfb90)
11-26 08:41:39.846: E/AndroidRuntime(2391): FATAL EXCEPTION: main
11-26 08:41:39.846: E/AndroidRuntime(2391): Process: com.thenewboston.christoph, PID: 2391
11-26 08:41:39.846: E/AndroidRuntime(2391): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thenewboston.christoph/com.thenewboston.christoph.StartingPoint}: java.lang.NullPointerException
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.app.ActivityThread.access$700(ActivityThread.java:135)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.os.Handler.dispatchMessage(Handler.java:102)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.os.Looper.loop(Looper.java:137)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.app.ActivityThread.main(ActivityThread.java:4998)
11-26 08:41:39.846: E/AndroidRuntime(2391): at java.lang.reflect.Method.invokeNative(Native Method)
11-26 08:41:39.846: E/AndroidRuntime(2391): at java.lang.reflect.Method.invoke(Method.java:515)
11-26 08:41:39.846: E/AndroidRuntime(2391): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
11-26 08:41:39.846: E/AndroidRuntime(2391): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
11-26 08:41:39.846: E/AndroidRuntime(2391): at dalvik.system.NativeStart.main(Native Method)
11-26 08:41:39.846: E/AndroidRuntime(2391): Caused by: java.lang.NullPointerException
11-26 08:41:39.846: E/AndroidRuntime(2391): at com.thenewboston.christoph.StartingPoint.onCreate(StartingPoint.java:32)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.app.Activity.performCreate(Activity.java:5243)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-26 08:41:39.846: E/AndroidRuntime(2391): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
11-26 08:41:39.846: E/AndroidRuntime(2391): ... 11 more
11-26 08:41:39.986: W/ActivityManager(371): Force finishing activity com.thenewboston.christoph/.StartingPoint
11-26 08:41:42.186: W/ActivityManager(371): Activity pause timeout for ActivityRecord{b20bd328 u0 com.thenewboston.christoph/.StartingPoint t35 f}
11-26 08:41:44.446: I/Choreographer(371): Skipped 33 frames! The application may be doing too much work on its main thread.
11-26 08:41:45.026: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.026: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.026: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.026: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.026: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.026: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.026: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.026: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.036: E/SoundPool(371): error loading /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.036: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
11-26 08:41:45.036: E/SoundPool(371): error loading /system/media/audio/ui/KeypressStandard.ogg
11-26 08:41:45.036: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
11-26 08:41:45.036: E/SoundPool(371): error loading /system/media/audio/ui/KeypressSpacebar.ogg
11-26 08:41:45.036: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
11-26 08:41:45.036: E/SoundPool(371): error loading /system/media/audio/ui/KeypressDelete.ogg
11-26 08:41:45.036: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
11-26 08:41:45.036: E/SoundPool(371): error loading /system/media/audio/ui/KeypressReturn.ogg
11-26 08:41:45.036: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
11-26 08:41:45.036: E/SoundPool(371): error loading /system/media/audio/ui/KeypressInvalid.ogg
11-26 08:41:45.036: W/AudioService(371): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
11-26 08:41:45.036: W/AudioService(371): onLoadSoundEffects(), Error -1 while loading samples
11-26 08:41:45.356: I/Process(2391): Sending signal. PID: 2391 SIG: 9
11-26 08:41:45.406: I/ActivityManager(371): Process com.thenewboston.christoph (pid 2391) has died.
11-26 08:41:45.436: I/WindowState(371): WIN DEATH: Window{b20c73c8 u0 com.thenewboston.christoph/com.thenewboston.christoph.Splash}
11-26 08:41:45.446: I/Choreographer(371): Skipped 50 frames! The application may be doing too much work on its main thread.
11-26 08:41:45.466: W/Looper(371): Ignoring unexpected epoll events 0x11 on fd 181 that is no longer registered.
11-26 08:41:48.566: W/InputMethodManagerService(371): Got RemoteException sending setActive(false) notification to pid 2391 uid 10051
11-26 08:41:48.586: W/Binder(505): Caught a RuntimeException from the binder stub implementation.
11-26 08:41:48.586: W/Binder(505): java.lang.NullPointerException
11-26 08:41:48.586: W/Binder(505): at android.inputmethodservice.IInputMethodWrapper.setSessionEnabled(IInputMethodWrapper.java:280)
11-26 08:41:48.586: W/Binder(505): at com.android.internal.view.IInputMethod$Stub.onTransact(IInputMethod.java:129)
11-26 08:41:48.586: W/Binder(505): at android.os.Binder.execTransact(Binder.java:404)
11-26 08:41:48.586: W/Binder(505): at dalvik.system.NativeStart.run(Native Method)
11-26 08:41:48.676: I/Choreographer(531): Skipped 97 frames! The application may be doing too much work on its main thread.
11-26 08:41:48.786: W/WindowManager(371): Rebuild removed 2 windows but added 1
11-26 08:41:48.786: W/WindowManager(371): java.lang.RuntimeException: here
11-26 08:41:48.786: W/WindowManager(371): at com.android.server.wm.WindowManagerService.rebuildAppWindowListLocked(WindowManagerService.java:7985)
11-26 08:41:48.786: W/WindowManager(371): at com.android.server.wm.WindowManagerService.rebuildAppWindowListLocked(WindowManagerService.java:7921)
11-26 08:41:48.786: W/WindowManager(371): at com.android.server.wm.WindowManagerService.handleAnimatingStoppedAndTransitionLocked(WindowManagerService.java:8660)
11-26 08:41:48.786: W/WindowManager(371): at com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLockedInner(WindowManagerService.java:9183)
11-26 08:41:48.786: W/WindowManager(371): at com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLockedLoop(WindowManagerService.java:8137)
11-26 08:41:48.786: W/WindowManager(371): at com.android.server.wm.WindowManagerService.performLayoutAndPlaceSurfacesLocked(WindowManagerService.java:8079)
11-26 08:41:48.786: W/WindowManager(371): at com.android.server.wm.WindowManagerService.access$300(WindowManagerService.java:157)
11-26 08:41:48.786: W/WindowManager(371): at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:7139)
11-26 08:41:48.786: W/WindowManager(371): at android.os.Handler.dispatchMessage(Handler.java:102)
11-26 08:41:48.786: W/WindowManager(371): at android.os.Looper.loop(Looper.java:137)
11-26 08:41:48.786: W/WindowManager(371): at android.os.HandlerThread.run(HandlerThread.java:61)
11-26 08:41:48.796: W/WindowManager(371): This window was lost: Window{b20c73c8 u0 com.thenewboston.christoph/com.thenewboston.christoph.Splash}
11-26 08:41:48.796: W/WindowManager(371): mDisplayId=0 mSession=Session{b208dd60 2391:u0a10051} mClient=android.os.BinderProxy@b208a2a0
11-26 08:41:48.796: W/WindowManager(371): mOwnerUid=10051 mShowToOwnerOnly=true package=com.thenewboston.christoph appop=NONE
11-26 08:41:48.796: W/WindowManager(371): mAttrs=WM.LayoutParams{(0,0)(fillxfill) sim=#120 ty=1 fl=#1810100 pfl=0x8 wanim=0x10302a1}
11-26 08:41:48.796: W/WindowManager(371): Requested w=720 h=1184 mLayoutSeq=921
11-26 08:41:48.796: W/WindowManager(371): mBaseLayer=21000 mSubLayer=0 mAnimLayer=21005+0=21005 mLastLayer=21005
11-26 08:41:48.796: W/WindowManager(371): mToken=AppWindowToken{b230b600 token=Token{b201ba40 ActivityRecord{b206c920 u0 com.thenewboston.christoph/.Splash t35}}}
11-26 08:41:48.796: W/WindowManager(371): mRootToken=AppWindowToken{b230b600 token=Token{b201ba40 ActivityRecord{b206c920 u0 com.thenewboston.christoph/.Splash t35}}}
11-26 08:41:48.796: W/WindowManager(371): mAppToken=AppWindowToken{b230b600 token=Token{b201ba40 ActivityRecord{b206c920 u0 com.thenewboston.christoph/.Splash t35}}}
11-26 08:41:48.796: W/WindowManager(371): mViewVisibility=0x0 mHaveFrame=true mObscured=false
11-26 08:41:48.796: W/WindowManager(371): mSeq=0 mSystemUiVisibility=0x0
11-26 08:41:48.796: W/WindowManager(371): mGivenContentInsets=[0,0][0,0] mGivenVisibleInsets=[0,0][0,0]
11-26 08:41:48.796: W/WindowManager(371): mConfiguration={1.0 310mcc260mnc en_US ldltr sw360dp w360dp h567dp 320dpi nrml port finger qwerty/v/v -nav/h s.5}
11-26 08:41:48.796: W/WindowManager(371): mHasSurface=true mShownFrame=[0.0,0.0][720.0,1184.0] isReadyForDisplay()=false
11-26 08:41:48.796: W/WindowManager(371): mFrame=[0,0][720,1184] last=[0,0][720,1184]
11-26 08:41:48.796: W/WindowManager(371): mSystemDecorRect=[0,50][720,1184] last=[0,50][720,1184]
11-26 08:41:48.796: W/WindowManager(371): Frames: containing=[0,0][720,1184] parent=[0,0][720,1184]
11-26 08:41:48.796: W/WindowManager(371): display=[0,0][720,1184] overscan=[0,0][720,1280]
11-26 08:41:48.796: W/WindowManager(371): content=[0,50][720,1184] visible=[0,50][720,1184]
11-26 08:41:48.796: W/WindowManager(371): decor=[0,50][720,1184]
11-26 08:41:48.796: W/WindowManager(371): Cur insets: overscan=[0,0][0,0] content=[0,50][0,0] visible=[0,50][0,0]
11-26 08:41:48.796: W/WindowManager(371): Lst insets: overscan=[0,0][0,0] content=[0,50][0,0] visible=[0,50][0,0]
11-26 08:41:48.796: W/WindowManager(371): WindowStateAnimator{b22c8a08 com.thenewboston.christoph/com.thenewboston.christoph.Splash}:
11-26 08:41:48.796: W/WindowManager(371): mSurface=Surface(name=com.thenewboston.christoph/com.thenewboston.christoph.Splash)
11-26 08:41:48.796: W/WindowManager(371): mDrawState=HAS_DRAWN mLastHidden=true
11-26 08:41:48.796: W/WindowManager(371): Surface: shown=false layer=21005 alpha=1.0 rect=(0.0,0.0) 720.0 x 1184.0
11-26 08:41:48.796: W/WindowManager(371): mGlobalScale=1.0 mDsDx=1.0 mDtDx=0.0 mDsDy=0.0 mDtDy=1.0
11-26 08:41:48.796: W/WindowManager(371): mExiting=false mRemoveOnExit=false mDestroying=true mRemoved=false
11-26 08:41:48.806: W/WindowManager(371): Current app token list:
11-26 08:41:48.806: V/WindowManager(371): Display 0
11-26 08:41:48.816: V/WindowManager(371): #1: Token{b207c918 ActivityRecord{b1fee0f8 u0 com.android.launcher/com.android.launcher2.Launcher t1}}
11-26 08:41:48.856: V/WindowManager(371): #0: Token{b233b8f8 ActivityRecord{b2094c38 u0 com.android.quicksearchbox/.SearchActivity t20}}
11-26 08:41:48.856: W/WindowManager(371): Final window list:
11-26 08:41:48.856: V/WindowManager(371): #0: Window{b1f7c708 u0 SearchPanel}
11-26 08:41:48.856: V/WindowManager(371): #1: Window{b1fb8890 u0 NavigationBar}
11-26 08:41:48.856: V/WindowManager(371): #2: Window{b20b8e70 u0 StatusBar}
11-26 08:41:48.856: V/WindowManager(371): #3: Window{b2011000 u0 Keyguard}
11-26 08:41:48.856: V/WindowManager(371): #4: Window{b1fabae8 u0 KeyguardScrim}
11-26 08:41:48.856: V/WindowManager(371): #5: Window{b20b1338 u0 com.android.launcher/com.android.launcher2.Launcher}
11-26 08:41:48.856: V/WindowManager(371): #6: Window{b1ffe8b0 u0 com.android.systemui.ImageWallpaper}
11-26 08:41:49.596: W/ActivityManager(371): Launch timeout has expired, giving up wake lock!

最佳答案

像这样更改此代码

add = (Button) findViewById(R.id.bAdd);
sub = (Button) findViewById(R.id.bSub);
display = (TextView) findViewById(R.id.tvDisplay);

关于Android 应用程序错误 “Unfortunately App has Stopped” - 编程新手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20218262/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com