在我没有编译时错误,所以我试图在模拟器螺母上运行我的代码它停止不幸我不知道如何遵循logcat,这里我放置我的logcat任何人帮助我找到问题
12-14 23:02:20.816: D/dalvikvm(845): Not late-enabling CheckJNI (already on)
12-14 23:02:21.516: D/dalvikvm(845): newInstance failed: no <init>()
12-14 23:02:21.556: D/AndroidRuntime(845): Shutting down VM
12-14 23:02:21.556: W/dalvikvm(845): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
12-14 23:02:21.666: E/AndroidRuntime(845): FATAL EXCEPTION: main
12-14 23:02:21.666: E/AndroidRuntime(845): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sri.alinwallpaper/com.sri.alinwallpaper.MyPoint}: java.lang.InstantiationException: can't instantiate class com.sri.alinwallpaper.MyPoint; no empty constructor
12-14 23:02:21.666: E/AndroidRuntime(845): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
12-14 23:02:21.666: E/AndroidRuntime(845): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-14 23:02:21.666: E/AndroidRuntime(845): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-14 23:02:21.666: E/AndroidRuntime(845): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-14 23:02:21.666: E/AndroidRuntime(845): at android.os.Handler.dispatchMessage(Handler.java:99)
12-14 23:02:21.666: E/AndroidRuntime(845): at android.os.Looper.loop(Looper.java:137)
12-14 23:02:21.666: E/AndroidRuntime(845): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-14 23:02:21.666: E/AndroidRuntime(845): at java.lang.reflect.Method.invokeNative(Native Method)
12-14 23:02:21.666: E/AndroidRuntime(845): at java.lang.reflect.Method.invoke(Method.java:511)
12-14 23:02:21.666: E/AndroidRuntime(845): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-14 23:02:21.666: E/AndroidRuntime(845): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-14 23:02:21.666: E/AndroidRuntime(845): at dalvik.system.NativeStart.main(Native Method)
12-14 23:02:21.666: E/AndroidRuntime(845): Caused by: java.lang.InstantiationException: can't instantiate class com.sri.alinwallpaper.MyPoint; no empty constructor
12-14 23:02:21.666: E/AndroidRuntime(845): at java.lang.Class.newInstanceImpl(Native Method)
12-14 23:02:21.666: E/AndroidRuntime(845): at java.lang.Class.newInstance(Class.java:1319)
12-14 23:02:21.666: E/AndroidRuntime(845): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
12-14 23:02:21.666: E/AndroidRuntime(845): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
12-14 23:02:21.666: E/AndroidRuntime(845): ... 11 more
12-14 23:02:25.496: I/Process(845): Sending signal. PID: 845 SIG: 9
答案 0 :(得分:1)
您可能需要提供一个不为MyPoint
类提供任何参数的构造函数。
像
这样的东西public MyPoint() {
super();
}
发布您的整个代码,以便我们确认是这种情况。
答案 1 :(得分:0)
您可以使用MyPoint()类对象,并且不要初始化该对象