解决android 布局报错android.view.InflateException: Binary XML file line

V/WindowManager( 2076): addAppToken: AppWindowToken{ee2cdaf
token=Token{2439718e ActivityRecord{15fccd89 u0
com.xxx.xxx.xxx/.MainActivity t197}}} to stack=4 task=197 at 0
W/WindowManager( 2076): Token{2439718e ActivityRecord{15fccd89 u0
com.xxx.xxx.xxx/.MainActivity t197}} failed creating starting window
W/WindowManager( 2076): android.view.InflateException: Binary XML file
line #35: Error inflating class W/WindowManager( 2076):
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
W/WindowManager( 2076): at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
W/WindowManager( 2076): at
android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
W/WindowManager( 2076): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
W/WindowManager( 2076): at
android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
W/WindowManager( 2076): at
android.view.LayoutInflater.inflate(LayoutInflater.java:504)
W/WindowManager( 2076): at
android.view.LayoutInflater.inflate(LayoutInflater.java:414)
W/WindowManager( 2076): at
android.view.LayoutInflater.inflate(LayoutInflater.java:365)
W/WindowManager( 2076): at
com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:3605)
W/WindowManager( 2076): at
com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:3677)
W/WindowManager( 2076): at
com.android.internal.policy.impl.PhoneWindow.getDecorView(PhoneWindow.java:1943)
W/WindowManager( 2076): at
com.android.internal.policy.impl.PhoneWindowManager.addStartingWindow(PhoneWindowManager.java:2144)
W/WindowManager( 2076): at
com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:7915)
W/WindowManager( 2076): at
android.os.Handler.dispatchMessage(Handler.java:102) W/WindowManager(
2076): at android.os.Looper.loop(Looper.java:135)
W/WindowManager( 2076): at
android.os.HandlerThread.run(HandlerThread.java:61) W/WindowManager(
2076): at
com.android.server.ServiceThread.run(ServiceThread.java:46)
W/WindowManager( 2076): Caused by:
java.lang.reflect.InvocationTargetException W/WindowManager( 2076):
at java.lang.reflect.Constructor.newInstance(Native Method)
W/WindowManager( 2076): at
java.lang.reflect.Constructor.newInstance(Constructor.java:288)
W/WindowManager( 2076): at
android.view.LayoutInflater.createView(LayoutInflater.java:607)
W/WindowManager( 2076): … 16 more W/WindowManager( 2076):
Caused by: java.lang.RuntimeException: Failed to resolve attribute at
index 0 W/WindowManager( 2076): at
android.content.res.TypedArray.getDrawable(TypedArray.java:747)
W/WindowManager( 2076): at
android.widget.FrameLayout.(FrameLayout.java:123)
W/WindowManager( 2076): at
android.widget.FrameLayout.(FrameLayout.java:111)
W/WindowManager( 2076): at
android.widget.FrameLayout.(FrameLayout.java:107)

解决办法

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.3'

    defaultConfig {
        applicationId "com.xxx.xxx.xxx"
        minSdkVersion 17
        targetSdkVersion 25
    }

将targetSdkVersion 25改为targetSdkVersion 17

你可能感兴趣的:(android)