有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何使用Glide 安卓从facebook个人资料加载图像?

我有一个安卓应用程序,我将facebook个人资料照片加载到一个ImageView中,它可以很好地使用以下代码:

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

其中user.getPhoto()是:

FirebaseUser.getPhotoUrl().toString();

此url是:https://graph.facebook.com/2454203947934714/picture"

问题是我有了一部新手机,它已经不能用了。这是运行安卓10的小米Redmi note 9。我想知道Android 10版本有什么问题,但它不会在logcat上抛出异常或错误消息

我尝试过一些类似的变化:

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没有被调用,它实际上转到了onResourceReady,但是图像根本没有出现

我比较了两个不同设备的行为,它的流程是一样的,唯一的区别是在Android 10设备上它不显示de图像,而其他设备显示的图像与预期的一样

在运行代码的滑动行后立即记录:

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 = 安卓.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=安卓.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=[安卓.app.servertransaction.TopResumedActivityChangeItem] }) because of 2 msg, msg 2 took 11326ms (seq=158 running=713ms runnable=12ms io=6ms late=10ms h=安卓.app.ActivityThread$H w=159)
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = 安卓.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=安卓.app.servertransaction.StopActivityItem }) because of 27 msg, msg 1 took 11326ms (seq=158 running=713ms runnable=12ms io=6ms late=10ms h=安卓.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.安卓.gms.measurement.internal.zzjp@b3aaa36
        at 安卓.app.LoadedApk.forgetServiceDispatcher(LoadedApk.java:1759)
        at 安卓.app.ContextImpl.unbindService(ContextImpl.java:1787)
        at 安卓.content.ContextWrapper.unbindService(ContextWrapper.java:751)
        at com.google.安卓.gms.common.stats.ConnectionTracker.zza(com.google.安卓.gms:play-services-basement@@17.3.0:55)
        at com.google.安卓.gms.common.stats.ConnectionTracker.unbindService(com.google.安卓.gms:play-services-basement@@17.3.0:50)
        at com.google.安卓.gms.measurement.internal.zziv.zzag(com.google.安卓.gms:play-services-measurement-impl@@17.5.0:245)
        at com.google.安卓.gms.measurement.internal.zziv.zzal(com.google.安卓.gms:play-services-measurement-impl@@17.5.0:262)
        at com.google.安卓.gms.measurement.internal.zziv.zzc(com.google.安卓.gms:play-services-measurement-impl@@17.5.0:336)
        at com.google.安卓.gms.measurement.internal.zziu.zza(com.google.安卓.gms:play-services-measurement-impl@@17.5.0:2)
        at com.google.安卓.gms.measurement.internal.zzai.run(com.google.安卓.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.安卓.gms.measurement.internal.zzfy.run(com.google.安卓.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=安卓.view.Choreographer$FrameHandler c=安卓.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

共 (2) 个答案

  1. # 1 楼答案

    您只需将以下内容添加到buil.gradle应用程序级别:

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

    然后创建如下java类:

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

    并使用 GlideApp.with(context)....代替Glide.with(context)

  2. # 2 楼答案

    问题出在facebookapi上,由于某种原因,该资源当时无法访问,几天后就正常化了