【问题标题】:How to add RecyclerView dependency - gradle 3 [duplicate]如何添加 RecyclerView 依赖项 - gradle 3 [重复]
【发布时间】:2017-10-31 13:21:30
【问题描述】:

我已经开始使用 android 和 Kotlin,但在创建 RecyclerView 时遇到了问题。到目前为止,我看到的是我有一个新的 gradle 版本,但我不知道如何包含我需要的依赖项。

您可以在下面看到我对 build.gradle (app) 的依赖项的外观

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
}

我猜问题出在依赖的 RecyclerView 中,我找不到如何使用它。

【问题讨论】:

  • 你试过这个compile 'com.android.support:recyclerview-v7:25.3.1'吗?
  • 你仍然可以在 Gradle 3.0 版中使用compile

标签: android gradle android-gradle-plugin kotlin


【解决方案1】:

尝试添加:

implementation 'com.android.support:recyclerview-v7:26.0.0-beta1'

【讨论】:

    【解决方案2】:

    如下图所示:

    dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:0.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
    compile 'com.android.support:recyclerview-v7:26.0.0-beta1'
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-20
      • 2014-09-21
      • 2014-07-26
      • 2023-03-11
      相关资源
      最近更新 更多