【问题标题】:Android MVVM : cannot generate view bindersAndroid MVVM:无法生成视图活页夹
【发布时间】:2018-03-23 03:20:17
【问题描述】:

我收到类似的错误

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'

我们非常感谢您的任何意见。

【问题讨论】:

标签: android mvvm data-binding android-databinding


【解决方案1】:

我要找到解决上述问题的方法。这是我在标签下的布局文件中犯的一些愚蠢的错误。我写过类似的代码

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

而不是

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

这里的区别在于 > 文本放置。我在这两者之间感到困惑。如果有人想将数组列表从您的 Java 文件发送到 xml 文件,则正确的解决方案是第二种。

【讨论】:

    猜你喜欢
    • 2018-03-23
    • 1970-01-01
    • 2017-06-22
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-25
    • 1970-01-01
    相关资源
    最近更新 更多