TextInputLayout使用gradle 2.3.x渲染错误

时间:2017-05-15 19:54:05

标签: android xml android-studio

我使用Android studio在我的项目中升级到Gradle 2.3.2。在2.3.x之前,我没有任何问题。以下xml段用于正常工作。现在它在Android studio的渲染模式下失败了。它在我的模拟器和测试设备上编译并运行良好,但我无法再在预览中查看xml。

XML

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:id="@+id/view"
            android:layout_marginLeft="16dp"
            android:layout_marginRight="16dp"
            android:transitionName="nodeNameTrans">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/nodeCustomName"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/prompt_customname"
                android:inputType="text"
                android:maxLines="1"
                android:textSize="30dp"
                android:gravity="center_horizontal"/>

        </android.support.design.widget.TextInputLayout>

XML错误

java.lang.NoSuchMethodError: android.support.v4.graphics.drawable.DrawableCompat.clearColorFilter(Landroid/graphics/drawable/Drawable;)V
at android.support.design.widget.TextInputLayout.updateEditTextBackground(TextInputLayout.java:897)
at android.support.design.widget.TextInputLayout.drawableStateChanged(TextInputLayout.java:1392)
at android.view.View.refreshDrawableState(View.java:17922)
at android.view.View.dispatchAttachedToWindow(View.java:15427)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2953)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2960)
at android.view.AttachInfo_Accessor.setAttachInfo(AttachInfo_Accessor.java:42)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:333)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:567)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:549)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$1(RenderTask.java:680)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

如果我通过删除EditText来破坏xml,渲染似乎有效,但它当然会破坏我的布局。

的build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
  applicationId "XX.XX.XX.XXXXXXXX"
  minSdkVersion 16
  targetSdkVersion 25
  versionCode 389
  versionName '1.6.610 '
  vectorDrawables.useSupportLibrary = true

  //jackOptions {
  //  enabled true
  //}
}

buildTypes {
  release {
    minifyEnabled true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    debuggable false
    zipAlignEnabled true
    versionNameSuffix 'Release'
  }
  releaseDebug {
    //minifyEnabled true
    //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    //debuggable false
    //zipAlignEnabled true
    versionNameSuffix 'Beta'
    debuggable true
    jniDebuggable true
    minifyEnabled false
    zipAlignEnabled true
  }
  debug {
    //minifyEnabled false
    //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    debuggable true
    versionNameSuffix 'Beta'
  }
}

sourceSets.main.jni.srcDirs = []
externalNativeBuild {
  ndkBuild {
    path 'src/main/jni/Android.mk'
  }
 }
}

dependencies {
//compile fileTree(include: ['*.jar'], dir: 'libs')
//wearApp project(':wear')
compile ('com.android.support.constraint:constraint-layout:1.0.2')
compile ('com.android.support:support-compat:25.3.1')
compile ('com.android.support:appcompat-v7:25.3.1')
compile ('com.android.support:design:25.3.1')
compile ('com.google.android.gms:play-services-auth:10.2.4')
compile ('com.google.android.gms:play-services-analytics:10.2.4')
compile project(':mstb')
}
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:0)

我在我的mstb lib中有一个依赖项,我移动到我的主应用程序项目,它开始工作。

"?, ?, ?, ?, ?"

为什么这会导致它,我不知道。