我创建了一个应用程序,它适用于较旧的Android版本(Min API为10),但是当我在其他设备(Android 4.4.2)中安装它时,该应用程序无法正常工作,我收到了&#39 ;应用没响应'屏幕。有什么帮助吗?
当我在菜单中选择一个位置时应用程序崩溃,该位置应该会打开一个新活动......
谢谢,无论如何
-Edit(错误消息) -
07-20 16:55:26.766 22142-22142/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.desenvolvimento.sqlteste, PID: 22142
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.desenvolvimento.sqlteste/com.example.desenvolvimento.sqlteste.LoginActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1852)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1552)
at android.app.Activity.startActivityForResult(Activity.java:3746)
at android.app.Activity.startActivityForResult(Activity.java:3707)
at android.app.Activity.startActivity(Activity.java:4027)
at android.app.Activity.startActivity(Activity.java:3989)
at com.example.desenvolvimento.sqlteste.MainActivity$1.onItemClick(MainActivity.java:33)
at android.widget.AdapterView.performItemClick(AdapterView.java:300)
at android.widget.AbsListView.performItemClick(AbsListView.java:1143)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3044)
at android.widget.AbsListView.onTouchUp(AbsListView.java:3845)
at android.widget.AbsListView.onTouchEvent(AbsListView.java:3617)
at android.view.View.dispatchTouchEvent(View.java:8393)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2426)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2158)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2432)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2432)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2432)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2432)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2172)
at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2314)
at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1692)
at android.app.Activity.dispatchTouchEvent(Activity.java:2749)
at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2275)
at android.view.View.dispatchPointerEvent(View.java:8583)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4091)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3957)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3509)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3562)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3528)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3638)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3536)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3695)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3509)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3562)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3528)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3536)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3509)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5806)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5745)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5716)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5896)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:192)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:143)
at android.os.Looper.loop(Looper.java:122)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.refl
-New logcat
07-20 17:22:47.931 26650-26650/? E/AndroidRuntime? FATAL EXCEPTION: main
Process: com.example.desenvolvimento.sqlteste, PID: 26650
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.desenvolvimento.sqlteste/com.example.desenvolvimento.sqlteste.LoginActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2314)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayHomeAsUpEnabled(boolean)' on a null object reference
at com.example.desenvolvimento.sqlteste.LoginActivity.setupActionBar(LoginActivity.java:120)
at com.example.desenvolvimento.sqlteste.LoginActivity.onCreate(LoginActivity.java:35)
at android.app.Activity.performCreate(Activity.java:5953)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
答案 0 :(得分:1)
您需要在com.example.desenvolvimento.sqlteste.LoginActivity
中正确声明AndroidManifest.xml
。由于你没有提供任何代码,这是最具体的答案。
请参阅Android Manifest documentation for activity
。
此外,下一步是分析LoginActivity
中的第120行投掷NullPointerException
的原因(根据您的例外日志)。
答案 1 :(得分:0)
您必须将新活动添加到AndroidManifest.xml文件