Rahul Sharma
Rahul Sharma

Reputation: 13593

Android MVVM : cannot generate view binders

I am getting an error like

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

Few minutes before, my code was running well and I was able to run the project. I have tried many solutions as given over stackoverflow but not able to find out actual solution to this problem.

My app level gradle is like

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'

Any input from your side is highly appreciated.

Upvotes: 1

Views: 220

Answers (1)

Rahul Sharma
Rahul Sharma

Reputation: 13593

I am to find the solution for my above problem. This is some silly mistake I have done in my layout file under tag. I have written code like

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

instead of

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

The difference here is for > and < text placement. I got confused between these two. Right solution is second one if some want to send arraylist from yout Java file to xml file.

Upvotes: 1

Related Questions