无法将Recyclerview导入我的项目

时间:2018-08-11 13:39:55

标签: android android-recyclerview

我尝试将Recyclerview依赖项导入到Android Studio中的项目中。但是它一直失败。有谁知道如何解决这个问题?我已经在下面附加了gradle文件。谢谢!

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:26.0.0'
implementation 'com.android.support:design:26.0.0'
implementation 'com.android.support:cardview-v7:26.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.onesignal:OneSignal:3.9.1'
implementation 'com.google.android.exoplayer:exoplayer:2.8.1'
implementation 'com.sothree.slidinguppanel:library:3.4.0'
implementation 'com.github.claucookie.miniequalizer:library:1.0.0'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
implementation 'com.google.android.ads.consent:consent-library:1.0.4'
implementation 'com.android.support:multidex:1.0.3'
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '27.1.1'
            }
        }
    }
}
    compile files('libs/android-support-v7-recyclerview.jar')
}
apply plugin: 'com.google.gms.google-services'

2 个答案:

答案 0 :(得分:0)

`<div class="about"> <img class="headshot" src="../img/headshot.jpg"> <div class="textbox">here is where my text is</div> <div>` 上添加依赖项。

`.about {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    text-align: center;
}

.headshot {
    max-height: auto;
    max-width: 25%;
}

.textbox {
    background-color: hotpink;
    width: 25%;
    height: auto;
}`

或者,您也可以从android studio菜单中添加lib / dependencies。

点击“ 构建”->“ 编辑库和依赖项”。 然后点击右侧的“ + ”按钮。

搜索任何库。

示例搜索“回收站”

然后从列表中选择“ com.android.support:recyclerview-v7:x.x.x ”并完成操作。

引用here

答案 1 :(得分:0)

您现在可以在Build.gradle中使用最新的依赖项。不需要:

compile files('libs/android-support-v7-recyclerview.jar')

只需添加如下:

implementation 'com.android.support:recyclerview-v7:27.1.1'

然后,您可以删除libs/文件夹中的文件。 其他版本:

https://developer.android.com/topic/libraries/support-library/revisions

您需要先在线才能下载文件等。