Binary XML file line #16 in: Error inflating class

Android xml布局文件中,

   android:foreground="?attr/selectableItemBackground"
	compileSdkVersion = 27
    minSdkVersion = 21
    targetSdkVersion = 27
2020-01-19 15:37:20.504 29770-29770/com.example.qixin E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.qixin, PID: 29770
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.qixin/com.example.qixin.app.fun.bbs.activity.VideoViewActivity}: android.view.InflateException: Binary XML file line #16 in com.example.qixin:layout/activity_video_view: Binary XML file line #16 in com.example.qixin:layout/activity_video_view: Error inflating class 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3447)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3594)
        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:2146)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7762)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
     Caused by: android.view.InflateException: Binary XML file line #16 in com.example.qixin:layout/activity_video_view: Binary XML file line #16 in com.example.qixin:layout/activity_video_view: Error inflating class 
     Caused by: android.view.InflateException: Binary XML file line #16 in com.example.qixin:layout/activity_video_view: Error inflating class 
     Caused by: java.lang.reflect.InvocationTargetException
        at java.lang.reflect.Constructor.newInstance0(Native Method)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
        at android.view.LayoutInflater.createView(LayoutInflater.java:854)
        at android.view.LayoutInflater.createView(LayoutInflater.java:776)
        at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:930)
        at android.view.LayoutInflater.onCreateView(LayoutInflater.java:950)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1004)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
        at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:511)
        at android.app.Activity.setContentView(Activity.java:3408)
        at com.lepu.app.fun.bbs.activity.VideoViewActivity.onCreate(VideoViewActivity.java:31)
        at android.app.Activity.performCreate(Activity.java:7981)
        at android.app.Activity.performCreate(Activity.java:7970)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3594)
        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:2146)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7762)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
2020-01-19 15:37:20.504 29770-29770/com.example.qixin E/AndroidRuntime: Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 35: TypedValue{t=0x2/d=0x7f040147 a=-1}
        at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:996)
        at android.content.res.TypedArray.getDrawable(TypedArray.java:980)
        at android.view.View.(View.java:6047)
        at android.widget.ImageView.(ImageView.java:193)
        at android.widget.ImageView.(ImageView.java:188)
        at android.widget.ImageView.(ImageView.java:184)
        	... 32 more

Binary XML file line #16 in: Error inflating class_第1张图片

解决办法

把foreground属性去掉

你可能感兴趣的:(Android)