轮播图那个案例,滑动到第二张图片的时候app闪退,求解决。。。

2020-11-12 21:17:35.617 18843-18843/? I/art: Late-enabling -Xcheck:jni
2020-11-12 21:17:35.657 18843-18843/com.example.image W/System: ClassLoader referenced unknown path: /data/app/com.example.image-1/lib/arm64
2020-11-12 21:17:35.666 18843-18843/com.example.image I/System: Daemon delayGCRequest, sDelayGCRequest=false, delay=true, sPendingGCRequest=false
2020-11-12 21:17:35.690 18843-18843/com.example.image 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
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/view/View$OnUnhandledKeyEventListener;
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2463)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:938)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:806)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:693)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:170)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void com.example.image.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:21)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6813)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1119)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2805)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2927)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1650)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.os.Looper.loop() (Looper.java:159)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6364)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:1096)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:883)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.image-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.image-1/lib/arm64, /system/lib64, /vendor/lib64]]
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String, boolean) (ClassLoader.java:380)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at java.lang.Class java.lang.ClassLoader.loadClass(java.lang.String) (ClassLoader.java:312)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener(android.view.View, androidx.core.view.OnApplyWindowInsetsListener) (ViewCompat.java:2463)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at android.view.ViewGroup androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor() (AppCompatDelegateImpl.java:938)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor() (AppCompatDelegateImpl.java:806)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void androidx.appcompat.app.AppCompatDelegateImpl.setContentView(int) (AppCompatDelegateImpl.java:693)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void androidx.appcompat.app.AppCompatActivity.setContentView(int) (AppCompatActivity.java:170)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void com.example.image.MainActivity.onCreate(android.os.Bundle) (MainActivity.java:21)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.Activity.performCreate(android.os.Bundle) (Activity.java:6813)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.Instrumentation.callActivityOnCreate(android.app.Activity, android.os.Bundle) (Instrumentation.java:1119)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at android.app.Activity android.app.ActivityThread.performLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent) (ActivityThread.java:2805)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.ActivityThread.handleLaunchActivity(android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:2927)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.ActivityThread.-wrap12(android.app.ActivityThread, android.app.ActivityThread$ActivityClientRecord, android.content.Intent, java.lang.String) (ActivityThread.java:-1)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.ActivityThread$H.handleMessage(android.os.Message) (ActivityThread.java:1650)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:102)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.os.Looper.loop() (Looper.java:159)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6364)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:1096)
2020-11-12 21:17:35.711 18843-18843/com.example.image I/art: at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:883)
2020-11-12 21:17:35.743 18843-18860/com.example.image D/OpenGLRenderer: RenderMonitor init!
2020-11-12 21:17:35.743 18843-18860/com.example.image D/OpenGLRenderer: RenderMonitor closed!
2020-11-12 21:17:35.822 18843-18860/com.example.image I/Adreno: QUALCOMM build : 28fbe1e, I1c3536cac6
Build Date : 12/27/16
OpenGL ES Shader Compiler Version: XE031.09.00.04
Local Branch :
Remote Branch :
Remote Branch :
Reconstruct Branch :
2020-11-12 21:17:35.827 18843-18860/com.example.image I/OpenGLRenderer: Initialized EGL, version 1.4
2020-11-12 21:17:35.827 18843-18860/com.example.image D/OpenGLRenderer: Swap behavior 1
2020-11-12 21:17:37.167 18843-18843/com.example.image I/System: Daemon delayGCRequest, sDelayGCRequest=true, delay=false, sPendingGCRequest=false
2020-11-12 21:17:37.912 18843-18843/com.example.image E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.image, PID: 18843
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:4457)
at android.view.ViewGroup.addView(ViewGroup.java:4298)
at androidx.viewpager.widget.ViewPager.addView(ViewPager.java:1485)
at android.view.ViewGroup.addView(ViewGroup.java:4238)
at android.view.ViewGroup.addView(ViewGroup.java:4211)
at com.example.image.MainActivity$1.instantiateItem(MainActivity.java:55)
at androidx.viewpager.widget.ViewPager.addNewItem(ViewPager.java:1010)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1224)
at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092)
at androidx.viewpager.widget.ViewPager$3.run(ViewPager.java:273)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:883)
at android.view.Choreographer.doCallbacks(Choreographer.java:689)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:869)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:159)
at android.app.ActivityThread.main(ActivityThread.java:6364)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1096)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:883)
2020-11-12 21:17:37.959 18843-18843/com.example.image I/Process: killProcess pid=18843
java.lang.RuntimeException
at android.os.Process.killProcess(Process.java:1258)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:111)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
2020-11-12 21:17:37.959 18843-18843/com.example.image I/Process: Sending signal. PID: 18843 SIG: 9
主要问题在于:The specified child already has a parent. You must call removeView() on the child's parent first 将代码修改为如图
你的模拟器版本是什么?是android4.1的吗?