简体   繁体   English

在API级别23中使用Android数据绑定

[英]Using Android Data Binding in API level 23

.NET developer new to the Android world here. .NET开发人员是Android新手。 I'm currently developing an app for the Vuzix M300 smart glasses. 我目前正在为Vuzix M300智能眼镜开发一个应用程序。 The Vuzix SDK uses Android 6.0 API Level 23. I would also like to use Android's Data Binding Library, but I'm having trouble getting my project to build with that enabled. Vuzix SDK使用Android 6.0 API级别23。我也想使用Android的数据绑定库,但是我无法在启用该功能的情况下构建我的项目。 My app build.gradle file originally was setup as follows: 我的应用程序build.gradle文件最初是按以下方式设置的:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 'Vuzix Corporation:Vuzix M300 SDK:23'
    defaultConfig {
        applicationId "xxx.xxxx"
        minSdkVersion 23
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        dataBinding { enabled = true }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

ext {
    support_version = '23.4.0'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation "com.android.support:appcompat-v7:$support_version"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

But that was giving me errors so I added the following line after some searching online: 但这给了我错误,因此我在网上搜索后添加了以下几行:

implementation "com.android.support:support-v4:$support_version"

This resulted in a different error, which is where I'm stumped: 这导致了另一个错误,这就是我难住的地方:

Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat Message{kind=ERROR, text=Program type already present: android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat, sources=[Unknown source file], tool name=Optional.of(D8)} 程序类型已存在:android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat消息{种类=错误,文本=程序已存在:android.support.v4.accessibilityservice.AccessibilityServiceInfoCompat,来源= [未知源文件],工具名称=可选。 ((D8)}

It seems the v4 support repository I added is causing conflicts with the v7 I already have in there, but I'm not sure how to get around this. 我添加的v4支持存储库似乎与那里已经存在的v7发生冲突,但是我不确定如何解决此问题。 I've run into the same error but for AsyncTasks as well. 除了AsyncTasks,我也遇到了相同的错误。

Does anyone have any ideas? 有人有什么想法吗? Would be much appreciated. 将不胜感激。

您不必显式添加implementation "com.android.support:support-v4:$support_version"支持库,因为V7兼容库隐式依赖于V4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM