简体   繁体   中英

How to load an image from facebook profile using Glide android?

I have an android app where I load the facebook profile photo into an ImageView and it was working just fine with the following code:

Glide.with(this).load(user.getPhotoPath()).apply(RequestOptions.circleCropTransform()).into(imageView);

where user.getPhoto() is:

FirebaseUser.getPhotoUrl().toString();

this url is: "https://graph.facebook.com/2454203947934714/picture"

The thing is I've got a new cellphone on which it simply does not work anymore. It's Xiaomi Redmi note 9 running Android 10. I'm wondering it's some issue with Android 10 version, but it throws no exception nor error messages on the logcat

I've tried some variations like this:

Glide.with(this).load(user.getPhotoPath()).listener(new RequestListener<Drawable>() {
            @Override
            public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                return false;
            }

            @Override
            public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                imageView.setImageDrawable(resource);
                return false;
            }
        }).apply(RequestOptions.circleCropTransform()).into(imageView);

onLoadFailed is not called, it really goes to onResourceReady but the image simply does not appear.

I've compared the behavior of two different devices, it flows the same way, that only difference is that on Android 10 device it does not show de image, other device display the image just as expected.

Log right after running the Glide line of code:

W/Glide: Failed to find GeneratedAppGlideModule. You should include an annotationProcessor compile dependency on com.github.bumptech.glide:compiler in your application and a @GlideModule annotated AppGlideModule implementation or LibraryGlideModules will be silently ignored
D/DRM/DcfDecoder: decodeDrmImageIfNeeded with stream left [2]
E/DRM/DcfDecoder: decodeDrmImageIfNeeded stream caught ClassCastException 
W/Activity: Slow Operation: Activity com.relyon.whib/.activity.ProfileActivity onCreate took 11212ms
I/FIAM.Display: Binding to activity: activity.ProfileActivity
I/FIAM.Headless: Setting display event component
V/FA: Activity resumed, time: 135955371
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = null, this = DecorView@d0c960a[]
D/ViewRootImpl[ProfileActivity]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@1fb94f1, this = DecorView@d0c960a[ProfileActivity]
W/Looper: Slow Looper main: Long Msg: seq=158 plan=12:28:45.868  late=10ms wall=11326ms running=713ms runnable=12ms io=6ms h=android.app.ActivityThread$H w=159
W/Looper: Slow Looper main: Activity com.relyon.whib/.activity.ProfileActivity is 11344ms late (wall=1ms running=0ms ClientTransaction{ callbacks=[android.app.servertransaction.TopResumedActivityChangeItem] }) because of 2 msg, msg 2 took 11326ms (seq=158 running=713ms runnable=12ms io=6ms late=10ms h=android.app.ActivityThread$H w=159)
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@9820841, this = DecorView@7dd9e1a[AdmChoosingProfileActivity]
W/Looper: Slow Looper main: Activity com.relyon.whib/.activity.adm.AdmChoosingProfileActivity is 1362ms late (wall=48ms running=35ms ClientTransaction{ lifecycleRequest=android.app.servertransaction.StopActivityItem }) because of 27 msg, msg 1 took 11326ms (seq=158 running=713ms runnable=12ms io=6ms late=10ms h=android.app.ActivityThread$H w=159)
V/FA: Inactivity, disconnecting from the service
W/ConnectionTracker: Exception thrown while unbinding
    java.lang.IllegalArgumentException: Service not registered: com.google.android.gms.measurement.internal.zzjp@b3aaa36
        at android.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1759)
        at android.app.ContextImpl.unbindService(ContextImpl.java:1787)
        at android.content.ContextWrapper.unbindService(ContextWrapper.java:751)
        at com.google.android.gms.common.stats.ConnectionTracker.zza(com.google.android.gms:play-services-basement@@17.3.0:55)
        at com.google.android.gms.common.stats.ConnectionTracker.unbindService(com.google.android.gms:play-services-basement@@17.3.0:50)
        at com.google.android.gms.measurement.internal.zziv.zzag(com.google.android.gms:play-services-measurement-impl@@17.5.0:245)
        at com.google.android.gms.measurement.internal.zziv.zzal(com.google.android.gms:play-services-measurement-impl@@17.5.0:262)
        at com.google.android.gms.measurement.internal.zziv.zzc(com.google.android.gms:play-services-measurement-impl@@17.5.0:336)
        at com.google.android.gms.measurement.internal.zziu.zza(com.google.android.gms:play-services-measurement-impl@@17.5.0:2)
        at com.google.android.gms.measurement.internal.zzai.run(com.google.android.gms:play-services-measurement-impl@@17.5.0:7)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at com.google.android.gms.measurement.internal.zzfy.run(com.google.android.gms:play-services-measurement-impl@@17.5.0:21)
D/View: [ANR Warning]onMeasure time too long, this =DecorView@d0c960a[ProfileActivity]time =401 ms
D/Surface: Surface::connect(this=0x7adebf5000,api=1)
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/Surface: Surface::setBufferCount(this=0x7adebf5000,bufferCount=3)
D/Surface: Surface::allocateBuffers(this=0x7adebf5000)
E/RecyclerView: No adapter attached; skipping layout
W/PersistentConnection: pc_0 - Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "userReceiverUID"' at report to your security and Firebase Database rules for better performance
I/OpenGLRenderer: Davey! duration=899ms; Flags=1, IntendedVsync=52794009076049, Vsync=52794092243049, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=52794092834069, AnimationStart=52794093094915, PerformTraversalsStart=52794093138685, DrawStart=52794743948839, SyncQueued=52794834746608, SyncStart=52794835456762, IssueDrawCommandsStart=52794835897377, SwapBuffers=52794903922992, FrameCompleted=52794909446685, DequeueBufferDuration=282000, QueueBufferDuration=2845000, 
D/Surface: Surface::disconnect(this=0x7adea82000,api=1)
I/Choreographer: Skipped 48 frames!  The application may be doing too much work on its main thread.
W/Looper: Slow Looper main: doFrame is 813ms late because of 4 msg, msg 1 took 843ms (seq=199 running=694ms runnable=4ms io=6ms late=83ms h=android.view.Choreographer$FrameHandler c=android.view.Choreographer$FrameDisplayEventReceiver)
I/OpenGLRenderer: Davey! duration=831ms; Flags=0, IntendedVsync=52794142150176, Vsync=52794940553376, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=52794955995531, AnimationStart=52794956357146, PerformTraversalsStart=52794958154377, DrawStart=52794959983608, SyncQueued=52794964348762, SyncStart=52794965064454, IssueDrawCommandsStart=52794965529454, SwapBuffers=52794970826069, FrameCompleted=52794974704146, DequeueBufferDuration=194000, QueueBufferDuration=1748000, 
W/PersistentConnection: pc_0 - Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "userSenderUID"' at report to your security and Firebase Database rules for better performance

The problem was in the facebook api, for some reason this resource could not be accessed by that time, it got normalized some days after.

You just add following to buil.gradle app level:

 annotationProcessor 'com.github.bumptech.glide:compiler:${Your_Glide_version}'
 annotationProcessor 'androidx.annotation:annotation:1.1.0'

then create java class like this:

@GlideModule
public class MyGlideApp extends AppGlideModule {
       // do nothing here
 }

and use GlideApp.with(context).... instead of Glide.with(context)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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