iT邦幫忙

0

加入了login的功能就開不了

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.alertdisplaydiscount2, PID: 10694
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.alertdisplaydiscount2/com.example.alertdisplaydiscount2.memberregister}: java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.appcompat.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.appcompat.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:903)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:809)
at androidx.appcompat.app.AppCompatDelegateImpl.initWindowDecorActionBar(AppCompatDelegateImpl.java:550)
at androidx.appcompat.app.AppCompatDelegateImpl.getSupportActionBar(AppCompatDelegateImpl.java:537)
at androidx.appcompat.app.AppCompatActivity.getSupportActionBar(AppCompatActivity.java:163)
at com.example.alertdisplaydiscount2.memberregister.onCreate(memberregister.java:19)
at android.app.Activity.performCreate(Activity.java:8000)
at android.app.Activity.performCreate(Activity.java:7984)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) 
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:223) 
at android.app.ActivityThread.main(ActivityThread.java:7656) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

    我們是想寫仿造蝦皮賣場下方bottomnavigationbar,然後點會員中心進行登入,但上網查login的教學並且實際寫進去就直接無法開啟了,有神人能幫忙解答嗎?

網路上的教學都是直接開新的project實作,所以也不知道問題是出在哪裡

https://ithelp.ithome.com.tw/upload/images/20211202/2014444336gao4QOVN.jpg

   主要是灰字點進去都紅字
fillano iT邦超人 1 級 ‧ 2021-12-02 14:13:10 檢舉
那個程式碼出問題?
fillano iT邦超人 1 級 ‧ 2021-12-02 15:43:30 檢舉
那你模仿的程式寫了什麼?有東西沒實做?

1 個回答

1
海綿寶寶
iT邦大神 1 級 ‧ 2021-12-02 15:50:04

Unable to start activity ComponentInfo{com.example.alertdisplaydiscount2/com.example.alertdisplaydiscount2.memberregister}:

程式錯在 ComponentInfo / memberregister 處

java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.appcompat.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference

setWindowCallback 引用的物件應為 object 而非 null (白話講就是 object 沒 init 成功)

我要發表回答

立即登入回答