我正在开发一款Android应用程序。当我试图在模拟器上运行它时,它会崩溃。这是我第一个Android应用程序,我无法找出错误的原因。有人可以指出我的错误吗?
LogCat
LogCat
Shutting down VM
FATAL EXCEPTION: main
Process: io.github.ishankgulati.breakout, PID: 3589
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{io.github.ishankgulati.breakout/io.github.ishankgulati.breakout.BreakoutGame}: java.lang.IllegalAccessException: void io.github.ishankgulati.breakout.BreakoutGame.<init>() is not accessible from java.lang.Class<android.app.Instrumentation>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
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.IllegalAccessException: void io.github.ishankgulati.breakout.BreakoutGame.<init>() is not accessible from java.lang.Class<android.app.Instrumentation>
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
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)
12-29 19:10:34.689 3589-3589/? I/Process: Sending signal. PID: 3589 SIG: 9
您可以在这里查看我的项目。
上述问题已解决,但应用程序仍崩溃。
LogCat
I/art: Not late-enabling -Xcheck:jni (already on)
I/art: Late-enabling JIT
I/art: JIT created with code_cache_capacity=2MB compile_threshold=1000
W/System: ClassLoader referenced unknown path: /data/app/io.github.ishankgulati.breakout-1/lib/x86
E/WVMExtractor: Failed to open libwvm.so: dlopen failed: library "libwvm.so" not found
I/OMXClient: Using client-side OMX mux.
D/MediaPlayer: setSubtitleAnchor in MediaPlayer
W/art: Suspending all threads took: 33.410ms
I/OMXClient: Using client-side OMX mux.
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.github.ishankgulati.breakout, PID: 2303
java.lang.RuntimeException: Unable to start activity ComponentInfo{io.github.ishankgulati.breakout/io.github.ishankgulati.breakout.BreakoutGame}: java.lang.NullPointerException: Attempt to write to field 'float android.graphics.RectF.left' 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 write to field 'float android.graphics.RectF.left' on a null object reference
at io.github.ishankgulati.breakout.MainMenu.<init>(MainMenu.java:33)
at io.github.ishankgulati.breakout.BreakoutGame$BreakoutView.<init>(BreakoutGame.java:84)
at io.github.ishankgulati.breakout.BreakoutGame$BreakoutView.<init>(BreakoutGame.java:51)
at io.github.ishankgulati.breakout.BreakoutGame.onCreate(BreakoutGame.java:29)
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)