google-developer-training / android-fundamentals-apps-v2

Other
649 stars 2.63k forks source link

Does anyone have this issue as well? #277

Closed codinguyy closed 1 year ago

codinguyy commented 3 years ago

I downloaded the code and ran the app and got this ecception, anyone else?

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.roomwordssample, PID: 17704 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.roomwordssample/com.example.android.roomwordssample.MainActivity}: java.lang.RuntimeException: Cannot create an instance of class com.example.android.roomwordssample.WordViewModel at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3341) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83) 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:2045) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7478) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941) Caused by: java.lang.RuntimeException: Cannot create an instance of class com.example.android.roomwordssample.WordViewModel at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:221) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:187) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150) at com.example.android.roomwordssample.MainActivity.onCreate(MainActivity.java:49) at android.app.Activity.performCreate(Activity.java:7989) at android.app.Activity.performCreate(Activity.java:7978) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3316) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)  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:2045)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:223)  at android.app.ActivityThread.main(ActivityThread.java:7478)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)  Caused by: java.lang.InstantiationException: java.lang.Class has no zero argument constructor at java.lang.Class.newInstance(Native Method) at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:219) at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:187)  at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150)  at com.example.android.roomwordssample.MainActivity.onCreate(MainActivity.java:49)  at android.app.Activity.performCreate(Activity.java:7989)  at android.app.Activity.performCreate(Activity.java:7978)  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3316)  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3485)  at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)  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:2045)  at android.os.Handler.dispatchMessage(Handler.java:106)  at android.os.Looper.loop(Looper.java:223)  at android.app.ActivityThread.main(ActivityThread.java:7478)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:941)