Android Build an Interactive Story App Finishing the User Interface Loading the First Page

Thomas Reese
PRO
Thomas Reese
Pro Student 1,411 Points

My app keeps crashing when I click the next button

2019-07-24 22:29:02.177 29592-29592/? I/art: Not late-enabling -Xcheck:jni (already on) 2019-07-24 22:29:02.177 29592-29592/? W/art: Unexpected CPU variant for X86 using defaults: x86 2019-07-24 22:29:02.288 29592-29592/com.thomas.interactivestory W/System: ClassLoader referenced unknown path: /data/app/com.thomas.interactivestory-1/lib/x86 2019-07-24 22:29:02.296 29592-29592/com.thomas.interactivestory I/InstantRun: starting instant run server: is main process 2019-07-24 22:29:02.373 29592-29592/com.thomas.interactivestory W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener; 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void com.thomas.interactivestory.ui.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:22) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6679) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2618) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2726) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1) 2019-07-24 22:29:02.406 29592-29592/com.thomas.interactivestory I/art: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1477) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.os.Looper.loop() (Looper.java:154) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.thomas.interactivestory-1/base.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_dependencies_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_0_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_1_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_2_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_3_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_4_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_5_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_6_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_7_apk.apk", zip file "/data/app/com.thomas.interactivestory-1/split_lib_slice_8_apk.apk", zip file "/data/app/com.thomas.interactivest 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void androidx.core.view.ViewCompat.setBackground(android.view.View, android.graphics.drawable.Drawable) (ViewCompat.java:2341) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void androidx.appcompat.widget.ActionBarContainer.<init>(android.content.Context, android.util.AttributeSet) (ActionBarContainer.java:62) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at java.lang.Object java.lang.reflect.Constructor.newInstance0!(java.lang.Object[]) (Constructor.java:-2) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at java.lang.Object java.lang.reflect.Constructor.newInstance(java.lang.Object[]) (Constructor.java:430) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.createView(java.lang.String, java.lang.String, android.util.AttributeSet) (LayoutInflater.java:645) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:787) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.createViewFromTag(android.view.View, java.lang.String, android.content.Context, android.util.AttributeSet) (LayoutInflater.java:727) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.view.LayoutInflater.rInflate(org.xmlpull.v1.XmlPullParser, android.view.View, android.content.Context, android.util.AttributeSet, boolean) (LayoutInflater.java:858) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.view.LayoutInflater.rInflateChildren(org.xmlpull.v1.XmlPullParser, android.view.View, android.util.AttributeSet, boolean) (LayoutInflater.java:821) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.inflate(org.xmlpull.v1.XmlPullParser, android.view.ViewGroup, boolean) (LayoutInflater.java:518) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup, boolean) (LayoutInflater.java:426) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at android.view.View android.view.LayoutInflater.inflate(int, android.view.ViewGroup) (LayoutInflater.java:377) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:607) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:518) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:466) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:140) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void com.thomas.interactivestory.ui.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:22) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6679) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1118) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2618) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2726) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1477) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.os.Looper.loop() (Looper.java:154) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6119) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:886) 2019-07-24 22:29:02.407 29592-29592/com.thomas.interactivestory I/art: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:776) 2019-07-24 22:29:02.558 29592-29608/com.thomas.interactivestory I/OpenGLRenderer: Initialized EGL, version 1.4 2019-07-24 22:29:02.558 29592-29608/com.thomas.interactivestory D/OpenGLRenderer: Swap behavior 1 2019-07-24 22:29:02.558 29592-29608/com.thomas.interactivestory W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without... 2019-07-24 22:29:02.558 29592-29608/com.thomas.interactivestory D/OpenGLRenderer: Swap behavior 0 2019-07-24 22:29:02.591 29592-29608/com.thomas.interactivestory D/EGL_emulation: eglCreateContext: 0x9ce83300: maj 3 min 0 rcv 3 2019-07-24 22:29:02.698 29592-29608/com.thomas.interactivestory D/EGL_emulation: eglMakeCurrent: 0x9ce83300: ver 3 0 (tinfo 0x9cef7690) 2019-07-24 22:29:02.700 29592-29608/com.thomas.interactivestory E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008cdf 2019-07-24 22:29:02.700 29592-29608/com.thomas.interactivestory E/eglCodecCommon: glUtilsParamSize: unknow param 0x00008824 2019-07-24 22:29:02.709 29592-29592/com.thomas.interactivestory I/ViewConfigCompat: Could not find method getScaledScrollFactor() on ViewConfiguration 2019-07-24 22:29:02.727 29592-29592/com.thomas.interactivestory W/art: Before Android 4.1, method int androidx.appcompat.widget.DropDownListView.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 2019-07-24 22:29:02.733 29592-29608/com.thomas.interactivestory D/EGL_emulation: eglMakeCurrent: 0x9ce83300: ver 3 0 (tinfo 0x9cef7690) 2019-07-24 22:29:07.318 29592-29592/com.thomas.interactivestory D/StoryActivity: Thomas 2019-07-24 22:29:07.329 29592-29592/com.thomas.interactivestory D/AndroidRuntime: Shutting down VM 2019-07-24 22:29:07.329 29592-29592/com.thomas.interactivestory E/AndroidRuntime: FATAL EXCEPTION: main Process: com.thomas.interactivestory, PID: 29592 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.thomas.interactivestory/com.thomas.interactivestory.ui.StoryActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageDrawable(android.graphics.drawable.Drawable)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageDrawable(android.graphics.drawable.Drawable)' on a null object reference at com.thomas.interactivestory.ui.StoryActivity.loadPage(StoryActivity.java:54) at com.thomas.interactivestory.ui.StoryActivity.onCreate(StoryActivity.java:45) at android.app.Activity.performCreate(Activity.java:6679) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)  at android.app.ActivityThread.-wrap12(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:154)  at android.app.ActivityThread.main(ActivityThread.java:6119)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Tonnie Fanadez
Tonnie Fanadez
UX Design Techdegree Graduate 22,043 Points

Hello Thomas Reese

Please Copy-Paste these 2 methods for me: public Page getPage(int pageNumber) {} on Story Class private void loadPage(int pageNumber) () from StoryActivity Class

Thanks,