2017-10-11 57 views
1

我得到了如下的错误的Android MVVM:无法生成视图粘合剂

Error:cannot generate view binders java.lang.StringIndexOutOfBoundsException: String index out of range: -8 

前几分钟,我的代码是运行良好,我能够运行该项目。我已经尝试了很多解决方案,因为通过了stackoverflow,但无法找到解决此问题的实际解决方案。

我的应用水平gradle这个就像

android { 

compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION) 
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION 

defaultConfig { 

    applicationId "com.xyz.abc" 
    minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION) 
    targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION) 
    versionCode 1 
    versionName "1.0" 

    vectorDrawables.useSupportLibrary = true 

} 

buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 

packagingOptions { 
    exclude 'META-INF/DEPENDENCIES.txt' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/notice.txt' 
    exclude 'META-INF/license.txt' 
    exclude 'META-INF/dependencies.txt' 
    exclude 'META-INF/LGPL2.1' 
} 

dataBinding { 
    enabled = true 
} 

compileOptions { 
    targetCompatibility 1.8 
    sourceCompatibility 1.8 
    } 

} 

repositories { 
mavenCentral() 
maven { url 'https://maven.fabric.io/public' } 
} 

dependencies { 

    compile 'com.android.support:appcompat-v7:26.1.0' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.android.support:design:26.1.0' 
    compile 'com.android.support:cardview-v7:26.1.0' 
    compile 'com.android.support:customtabs:26.1.0' 

    compile 'com.android.support:support-v4:26.1.0' 

} 
apply plugin: 'com.google.gms.google-services' 

从你身边的任何输入的高度赞赏。

+0

检查接受的答案https://stackoverflow.com/questions/33343411/data-binding-cannot-find-symbol-class-br/33414765 – Anonymous

+0

@Anonymous不为我工作 –

回答

1

我想为我的上述问题找到解决方案。这是我在标签下的布局文件中完成的一些愚蠢的错误。我已经写了这样的代码

<variable 
     name="deliveryPreferences" 
     type="java.util.ArrayList&gt;String&lt;" /> 

,而不是

<variable 
     name="deliveryPreferences" 
     type="java.util.ArrayList&lt;String&gt;" /> 

这里的区别是><文字位置。我在这两者之间感到困惑。正确的解决方案是第二个,如果有人想从你的Java文件发送ArrayList到XML文件。