我正在尝试上传用户个人资料图像并存储在firebase中.我的图像成功存储在firebase存储和用户数据库中.
当我上传它在屏幕上显示的图像时,但是一旦我保存并重新打开设置以查看配置文件图像,它就不显示,它只显示空白的白色屏幕(但重新打开时的名称和手机显示,只有图像不显示节目)
我附加了从db获取值并在ui中显示的代码,并添加了saveUserinformation(),当用户单击保存图像按钮时,该函数将被调用,此函数在db中保存名称,电话和配置文件.我在下面添加了数据库的屏幕截图,还添加了我得到的错误代码段.
我究竟做错了什么?
这是我控制台登录时滑行输出:
profile img here:target for:android.support.v7.Widget.AppCompatImageVIEw {528bbb2 V.ED..C .. …… ID 0,0-300,300#7f0a00b9 app:ID / profileImage} [CDS] rx超时:0
mCustomerDatabase.addValueEventListener(object :ValueEventListener{ overrIDe fun onDataChange(dataSnapshot: DataSnapshot) { if(dataSnapshot.exists() && dataSnapshot.childrenCount>0){ val map:Map<*,*> = dataSnapshot.value as Map<*,*> if(map["name"] !=null){ mname=map["name"].toString() mnameFIEld.setText(mname) } if(map["phone"]!=null){ mPhone=map["phone"].toString() mPhoneFIEld.setText(mPhone) } if(map["profileImageUrl"]!=null){ mProfileImageUrl=map["profileImageUrl"].toString() GlIDe.with(applicationContext).load(mProfileImageUrl).into(mProfileImage) val a=GlIDe.with(applicationContext).load(mProfileImageUrl).into(mProfileImage) print("profile img here:$a") } } } overrIDe fun onCancelled(p0: DatabaseError) { Todo("not implemented") //To change body of created functions use file | Settings | file Templates. } })
private fun saveUserinformation(){ mname=mnameFIEld.text.toString() mPhone=mPhoneFIEld.text.toString() val userInfo=HashMap<String,Any>() userInfo.put("name",mname) userInfo.put("phone",mPhone) mCustomerDatabase.updateChildren(userInfo) if(resultUri!=null){ val imagePath:StorageReference=mStorage.child("customer_profile_image").child(userID).child(resultUri.lastPathSegment ) val uploadTask:UploadTask=imagePath.putfile(resultUri) uploadTask.addOnSuccessListener(OnSuccessListener <UploadTask.TaskSnapshot>(){taskSnapshot-> val downloadUrl: Task<Uri> =taskSnapshot.storage.downloadUrl val newImage= HashMap<String,Any>() newImage["profileImageUrl"] = downloadUrl.toString() mCustomerDatabase.updateChildren(newImage) }).addOnFailureListener(OnFailureListener() { Toast.makeText(this,"Profile image not uploaded",Toast.LENGTH_SHORT).show() }) } finish() }
Load Failed for com.Google.androID.gms.tasks.zzu@c0645c1 with size [300x300] class com.bumptech.glIDe.load.engine.GlIDeException: Failed to load resource There were 3 causes: java.io.fileNotFoundException(/com.Google.androID.gms.tasks.zzu@c0645c1: open Failed: ENOENT (No such file or directory)) java.io.fileNotFoundException(No such file or directory) java.io.fileNotFoundException(No such file or directory) call GlIDeException#logRootCauses(String) for more detail Cause (1 of 3): class com.bumptech.glIDe.load.engine.GlIDeException: Fetching data Failed, class java.io.inputStream, LOCAL There was 1 cause: java.io.fileNotFoundException(/com.Google.androID.gms.tasks.zzu@c0645c1: open Failed: ENOENT (No such file or directory)) call GlIDeException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glIDe.load.engine.GlIDeException: Fetch Failed There was 1 cause: java.io.fileNotFoundException(/com.Google.androID.gms.tasks.zzu@c0645c1: open Failed: ENOENT (No such file or directory)) call GlIDeException#logRootCauses(String) for more detail Cause (1 of 1): class java.io.fileNotFoundException: /com.Google.androID.gms.tasks.zzu@c0645c1: open Failed: ENOENT (No such file or directory) Cause (2 of 3): class com.bumptech.glIDe.load.engine.GlIDeException: Fetching data Failed, class androID.os.ParcelfileDescriptor, LOCAL There was 1 cause: java.io.fileNotFoundException(No such file or directory) call GlIDeException#logRootCauses(String) for more detail Cause (1 of 1): class com.bumptech.glIDe.load.engine.GlIDeException: Fetch Failed There was 1 cause: java.io.fileNotFoundException(No such file or directory) call GlIDeException#logRootCauses(String) for more detail Cause (1 of 1): class java.io.fileNotFoundException: No such file or directory Cause (3 of 3): class com.bumptech.glIDe.load.engine.GlIDeException: Fetching data Failed, class androID.content.res.AssetfileDescriptor, LOCAL There was 1 cause: java.io.fileNotFoundException(No such file or directory) call GlIDeException#logRootCauses(String) for more detail Cause (1 of 1): class java.io.fileNotFoundException: No such file or directory02-04 15:21:14.109 25281-25281/com.Sarah.taxi I/GlIDe: Root cause (1 of 3) java.io.fileNotFoundException: /com.Google.androID.gms.tasks.zzu@c0645c1: open Failed: ENOENT (No such file or directory) at libcore.io.IoBrIDge.open(IoBrIDge.java:487) at java.io.fileinputStream.<init>(fileinputStream.java:76) at java.io.fileinputStream.<init>(fileinputStream.java:103) at androID.content.ContentResolver.openinputStream(ContentResolver.java:689) at com.bumptech.glIDe.load.data.StreamLocalUriFetcher.loadResourceFromUri(StreamLocalUriFetcher.java:85) at com.bumptech.glIDe.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:60) at com.bumptech.glIDe.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:15) at com.bumptech.glIDe.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:99) at com.bumptech.glIDe.load.engine.sourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glIDe.load.engine.DecodeJob.runGenerators(DecodeJob.java:302) at com.bumptech.glIDe.load.engine.DecodeJob.runWrapped(DecodeJob.java:272) at com.bumptech.glIDe.load.engine.DecodeJob.run(DecodeJob.java:233) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) at com.bumptech.glIDe.load.engine.executor.GlIDeExecutor$DefaultThreadFactory.run(GlIDeExecutor.java:446) Caused by: androID.system.ErrnoException: open Failed: ENOENT (No such file or directory) at libcore.io.Posix.open(Native Method) at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186) at libcore.io.IoBrIDge.open(IoBrIDge.java:473) at java.io.fileinputStream.<init>(fileinputStream.java:76) at java.io.fileinputStream.<init>(fileinputStream.java:103) at androID.content.ContentResolver.openinputStream(ContentResolver.java:689) at com.bumptech.glIDe.load.data.StreamLocalUriFetcher.loadResourceFromUri(StreamLocalUriFetcher.java:85) at com.bumptech.glIDe.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:60) at com.bumptech.glIDe.load.data.StreamLocalUriFetcher.loadResource(StreamLocalUriFetcher.java:15) at com.bumptech.glIDe.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:99) at com.bumptech.glIDe.load.engine.sourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glIDe.load.engine.DecodeJob.runGenerators(DecodeJob.java:302) at com.bumptech.glIDe.load.engine.DecodeJob.runWrapped(DecodeJob.java:272) at com.bumptech.glIDe.load.engine.DecodeJob.run(DecodeJob.java:233) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) at com.bumptech.glIDe.load.engine.executor.GlIDeExecutor$DefaultThreadFactory.run(GlIDeExecutor.java:446) 02-04 15:21:14.110 25281-25281/com.Sarah.taxi I/GlIDe: Root cause (2 of 3) java.io.fileNotFoundException: No such file or directory at androID.os.Parcel.openfileDescriptor(Native Method) at androID.os.ParcelfileDescriptor.openInternal(ParcelfileDescriptor.java:270) at androID.os.ParcelfileDescriptor.open(ParcelfileDescriptor.java:200) at androID.content.ContentResolver.openAssetfileDescriptor(ContentResolver.java:966) at androID.content.ContentResolver.openAssetfileDescriptor(ContentResolver.java:894) at com.bumptech.glIDe.load.data.fileDescriptorLocalUriFetcher.loadResource(fileDescriptorLocalUriFetcher.java:22) at com.bumptech.glIDe.load.data.fileDescriptorLocalUriFetcher.loadResource(fileDescriptorLocalUriFetcher.java:14) at com.bumptech.glIDe.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:99) at com.bumptech.glIDe.load.engine.sourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glIDe.load.engine.DecodeJob.runGenerators(DecodeJob.java:302) at com.bumptech.glIDe.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:397) at com.bumptech.glIDe.load.engine.sourceGenerator.onLoadFailed(SourceGenerator.java:119) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:153) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:144) at com.bumptech.glIDe.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:49) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:99) at com.bumptech.glIDe.load.engine.sourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glIDe.load.engine.DecodeJob.runGenerators(DecodeJob.java:302) at com.bumptech.glIDe.load.engine.DecodeJob.runWrapped(DecodeJob.java:272) at com.bumptech.glIDe.load.engine.DecodeJob.run(DecodeJob.java:233) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) at com.bumptech.glIDe.load.engine.executor.GlIDeExecutor$DefaultThreadFactory.run(GlIDeExecutor.java:446) Root cause (3 of 3) java.io.fileNotFoundException: No such file or directory at androID.os.Parcel.openfileDescriptor(Native Method) at androID.os.ParcelfileDescriptor.openInternal(ParcelfileDescriptor.java:270) at androID.os.ParcelfileDescriptor.open(ParcelfileDescriptor.java:200) at androID.content.ContentResolver.openAssetfileDescriptor(ContentResolver.java:966) at androID.content.ContentResolver.openAssetfileDescriptor(ContentResolver.java:894) at com.bumptech.glIDe.load.data.AssetfileDescriptorLocalUriFetcher.loadResource(AssetfileDescriptorLocalUriFetcher.java:22) at com.bumptech.glIDe.load.data.AssetfileDescriptorLocalUriFetcher.loadResource(AssetfileDescriptorLocalUriFetcher.java:13) at com.bumptech.glIDe.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:44) at com.bumptech.glIDe.load.engine.sourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glIDe.load.engine.DecodeJob.runGenerators(DecodeJob.java:302) at com.bumptech.glIDe.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:397) at com.bumptech.glIDe.load.engine.sourceGenerator.onLoadFailed(SourceGenerator.java:119) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:153) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:144) at com.bumptech.glIDe.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:49) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:99) at com.bumptech.glIDe.load.engine.sourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glIDe.load.engine.DecodeJob.runGenerators(DecodeJob.java:302) at com.bumptech.glIDe.load.engine.DecodeJob.onDataFetcherFailed(DecodeJob.java:397) at com.bumptech.glIDe.load.engine.sourceGenerator.onLoadFailed(SourceGenerator.java:119) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:153) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:144) at com.bumptech.glIDe.load.data.LocalUriFetcher.loadData(LocalUriFetcher.java:49) at com.bumptech.glIDe.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:99) at com.bumptech.glIDe.load.engine.sourceGenerator.startNext(SourceGenerator.java:62) at com.bumptech.glIDe.load.engine.DecodeJob.runGenerators(DecodeJob.java:302) at com.bumptech.glIDe.load.engine.DecodeJob.runWrapped(DecodeJob.java:272) at com.bumptech.glIDe.load.engine.DecodeJob.run(DecodeJob.java:233) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) at java.lang.Thread.run(Thread.java:818) at com.bumptech.glIDe.load.engine.executor.GlIDeExecutor$DefaultThreadFactory.run(GlIDeExecutor.java:446)
enter image description here
解决方法:
您收到以下错误:
Load Failed for com.Google.androID.gms.tasks.zzu@c0645c1
因为您正在尝试显示不存在的图像.正如我在您的数据库中看到的那样,profileImageUrl属性包含一个无效的图像URL.
看到红线?它实际上持有的是来自内存的对象的地址而不是图像URL.这是因为您在downloadUrl对象上调用toString()方法.所以你获取donwload url的方式是不正确的. This是获取网址的正确方法.一旦获得图像的URL并将其添加到数据库中,一切都将按预期工作.
总结以上是内存溢出为你收集整理的android – 保存后未显示的配置文件图像(它只显示空白屏幕)全部内容,希望文章能够帮你解决android – 保存后未显示的配置文件图像(它只显示空白屏幕)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)