2016-08-22 76 views
0

因此,我創建了一個名爲BagActivity的活動,它是適配器等,因爲它已不再需要而被刪除。我內置乾淨的項目,從測試的設備上卸載APK,然而,我得到以下錯誤:當活動不存在時無法啓動活動ComponentInfo

FATAL EXCEPTION: main 
                    Process: in.ddas.pretense, PID: 11858 
                    java.lang.RuntimeException: Unable to start activity ComponentInfo{in.ddas.pretense/in.ddas.pretense.BagActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference 
                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298) 
                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) 
                     at android.app.ActivityThread.access$800(ActivityThread.java:144) 
                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) 
                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                     at android.os.Looper.loop(Looper.java:135) 
                     at android.app.ActivityThread.main(ActivityThread.java:5221) 
                     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:899) 
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 
                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference 
                     at in.ddas.pretense.BagActivity.onCreate(BagActivity.java:28) 
                     at android.app.Activity.performCreate(Activity.java:5933) 
                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 
                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) 
                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)  
                     at android.app.ActivityThread.access$800(ActivityThread.java:144)  
                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)  
                     at android.os.Handler.dispatchMessage(Handler.java:102)  
                     at android.os.Looper.loop(Looper.java:135)  
                     at android.app.ActivityThread.main(ActivityThread.java:5221)  
                     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:899)  
                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)  

出了什麼問題? 謝謝。

編輯:如果我在不同的測試設備上運行此應用程序,則此錯誤不會顯示!爲什麼要顯示1個設備?

回答

1

看來你還沒有刪除所有的BugActivity員工。

您有一個例外:

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.v7.widget.RecyclerView.setLayoutManager(android.support.v7.widget.RecyclerView$LayoutManager)' on a null object reference 
      at in.ddas.pretense.BagActivity.onCreate(BagActivity.java:28) 

它造成第二個例外。因此它表示您嘗試在BagActivity的onCreate方法中使用null RecyclerView對象。您可以在不刪除活動類的情況下刪除BagActivity的佈局。

+0

我有,如果我在不同的設備上運行這個應用程序,這個錯誤不顯示! –

+0

你在哪個設備上有這個錯誤? – Volen

+0

Nexus 6摩托羅拉One? –

相關問題