当前位置:  开发笔记 > 编程语言 > 正文

android应用程序崩溃,并出现错误java.lang.RuntimeException:无法实例化活动ComponentInfo

如何解决《android应用程序崩溃,并出现错误java.lang.RuntimeException:无法实例化活动ComponentInfo》经验,为你挑选了1个好方法。

我正在开发一个android应用程序。当我尝试在模拟器上运行它时会崩溃。这是我的第一个android应用程序,我无法找出错误原因。有人可以指出错误吗?

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.() is not accessible from java.lang.Class
     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.() is not accessible from java.lang.Class
     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.(MainMenu.java:33)
   at io.github.ishankgulati.breakout.BreakoutGame$BreakoutView.(BreakoutGame.java:84)
   at io.github.ishankgulati.breakout.BreakoutGame$BreakoutView.(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) 

Blackbelt.. 5

你的 BreakoutGame

public class BreakoutGame extends Activity{

覆盖链接其可见性的默认构造函数。这导致了异常。不要这样 您希望在构造函数中进行的每个初始化都可以在框架调用的回调之一中完成。例如onCreate



1> Blackbelt..:

你的 BreakoutGame

public class BreakoutGame extends Activity{

覆盖链接其可见性的默认构造函数。这导致了异常。不要这样 您希望在构造函数中进行的每个初始化都可以在框架调用的回调之一中完成。例如onCreate

推荐阅读
殉情放开那只小兔子
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有