Android 使用API 28时不显示Recyclerview

Android 使用API 28时不显示Recyclerview,android,android-studio,android-recyclerview,Android,Android Studio,Android Recyclerview,我有一个android模块(我自己的lib),我用它从web上获取数据,并使用recyclerview将其显示为列表 数据由我通过毕加索库加载的图像路径组成。recyclerview列表中的每个项目都是一个ImageView 我使用的是androidx依赖项。当安装在带有API 24的仿真器中时,这些应用程序可以正常工作。但是,当应用程序安装在带有API 28的仿真器中时,数据不会显示 我已经为API 28进行了调试,数据按预期获取 这里是列表作为“it”从web返回的位置。调试时,列表中会出现

我有一个android模块(我自己的lib),我用它从web上获取数据,并使用recyclerview将其显示为列表

数据由我通过毕加索库加载的图像路径组成。recyclerview列表中的每个项目都是一个ImageView

我使用的是androidx依赖项。当安装在带有API 24的仿真器中时,这些应用程序可以正常工作。但是,当应用程序安装在带有API 28的仿真器中时,数据不会显示

我已经为API 28进行了调试,数据按预期获取

这里是列表作为“it”从web返回的位置。调试时,列表中会出现预期的20项。

viewModel.trendingsLiveData.observe(this, Observer {
        Log.d("trendingtitle", "trendingsLiveData.observe() called")
        allTrendingAdapter!!.loadItems(it)
        allTrendingAdapter!!.notifyDataSetChanged()

        shimmerViewContainer?.stopShimmer()//stopShimmerAnimation()
        shimmerViewContainer?.setVisibility(View.INVISIBLE)
    })
用于在适配器中加载图像的行(也使用断点检查-按预期工作)

Build.gradle(我的Android模块)

Build.gradle(模块应用程序)

Build.gradle(项目)


为什么图像列表显示在API 24中,而不显示在API 28中?

对于简单的修复,请使用
AndroidManifest.xml中的以下代码

 <application
        android:usesCleartextTraffic="true"
   ...>

要修复未加载的图像,请更换
http://image.tmdb.org
https://image.tmdb.org

请注意,各种应用程序扫描程序(如Play Protect)可能会将您的应用程序标记为有害/不安全。要得到更好的答案,请看我刚刚更改了正确的答案,因为它更安全。但两者都允许应用程序显示所需的数据。
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.0"


defaultConfig {
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'


def moshiVersion="1.8.0"
def retrofit2_version = "2.5.0"
def okhttp3_version = "3.12.0"
def kotlinCoroutineVersion = "1.0.1"
def picassoVersion = "2.71828"

//ViewModel Scope
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha01'

//recyclerview
implementation 'androidx.recyclerview:recyclerview:1.0.0'

implementation 'com.google.android.material:material:1.0.0'

//Moshi
implementation "com.squareup.moshi:moshi-kotlin:$moshiVersion"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"

//Retrofit2
implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit2_version"
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2"
//Because of an error with JAR version
implementation "org.jetbrains.kotlin:kotlin-reflect:'1.3.31'"

//Okhttp3
implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'

//Picasso
implementation ("com.squareup.picasso:picasso:$picassoVersion"){
    exclude group: "com.android.support"
}

implementation 'com.facebook.shimmer:shimmer:0.4.0'
}
apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 28
    buildToolsVersion "29.0.0"
    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation project(path: ':posterlistlib')
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.41'
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
 <application
        android:usesCleartextTraffic="true"
   ...>