Android10 Glide does not display when loading local pictures

Glide version:

'com.github.bumptech.glide:glide:4.11.0'

The code to load the image

Glide.with(this)
     .load(imgLocalPath)
     .into(imageView);

In the process of using, because of the problem of the simulator, the Android 8.0 version has been used, and the mobile phone is version 9.0. The project SDK configuration is as follows

compileSdkVersion 30
buildToolsVersion "30.0.0"
defaultConfig {
    applicationId "com.example.myapplication"
    minSdkVersion 26
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

After selecting the picture in the album, it has not been displayed on android10, and the permissions are also given

Found that the manifest lacks a configuration

android:requestLegacyExternalStorage="true"

Add under the <application> tag

You can also change the targetSdkVersion to 28 and below, but it is not recommended

The reason is that the file storage mechanism of Android 10 has been modified to sandbox mode. APP can only access files in its own directory and public media files under Android 10. The old file storage method is still used. Even if Android 10 obtains the read permission, it can access external storage. Was restricted.

Thanks https://www.jianshu.com/p/ba6419bc9059

 

Guess you like

Origin blog.csdn.net/qq_40516592/article/details/110847929