우물안에서 보는 하늘도 맑다

오틸라의 안드로이드 앱 만들기 강좌 : 힐링 #9 본문

경단녀에서 "나"로 돌아가기/안드로이드

오틸라의 안드로이드 앱 만들기 강좌 : 힐링 #9

몽염이 2020. 7. 25. 23:34
반응형

 

* FIrebase Storage 시작

 

 

* Cloud Storage 개발자 문서

https://firebase.google.com/docs/storage?authuser=0

* 스토리지 업로드 방식 중, 메모리 데이터에서 업로드 방식을 선택함

 

*  이미지를 선택하지 않고 저장 버튼을 눌렀을 때, 오류 발생

Load failed for https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Filhot.jpg&uploadType=resumable&upload_id=AAANsUmoPKKUSR5zaL6S3LuQjiQPxMIKVo59yiIie3X_69GAuROJYDVObgoDnSRTHWDCeABoGBBtdGS_ZGCLJ-egsGM&upload_protocol=resumable with size [175x175]

class com.bumptech.glide.load.engine.GlideException: Failed to load resource

There was 1 cause:

java.io.FileNotFoundException(https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Filhot.jpg&uploadType=resumable&upload_id=AAANsUmoPKKUSR5zaL6S3LuQjiQPxMIKVo59yiIie3X_69GAuROJYDVObgoDnSRTHWDCeABoGBBtdGS_ZGCLJ-egsGM&upload_protocol=resumable)

call GlideException#logRootCauses(String) for more detail

Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE

There was 1 cause:

java.io.FileNotFoundException(https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Filhot.jpg&uploadType=resumable&upload_id=AAANsUmoPKKUSR5zaL6S3LuQjiQPxMIKVo59yiIie3X_69GAuROJYDVObgoDnSRTHWDCeABoGBBtdGS_ZGCLJ-egsGM&upload_protocol=resumable)

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(https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Filhot.jpg&uploadType=resumable&upload_id=AAANsUmoPKKUSR5zaL6S3LuQjiQPxMIKVo59yiIie3X_69GAuROJYDVObgoDnSRTHWDCeABoGBBtdGS_ZGCLJ-egsGM&upload_protocol=resumable)

call GlideException#logRootCauses(String) for more detail

Cause (1 of 1): class java.io.FileNotFoundException: https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Filhot.jpg&uploadType=resumable&upload_id=AAANsUmoPKKUSR5zaL6S3LuQjiQPxMIKVo59yiIie3X_69GAuROJYDVObgoDnSRTHWDCeABoGBBtdGS_ZGCLJ-egsGM&upload_protocol=resumable

I/Glide: Root cause (1 of 1)

java.io.FileNotFoundException: https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Filhot.jpg&uploadType=resumable&upload_id=AAANsUmoPKKUSR5zaL6S3LuQjiQPxMIKVo59yiIie3X_69GAuROJYDVObgoDnSRTHWDCeABoGBBtdGS_ZGCLJ-egsGM&upload_protocol=resumable

at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)

at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211)

at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30)

at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:102)

at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:56)

at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)

at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:164)

at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)

at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:62)

at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)

at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:70)

at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:63)

at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:310)

at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:279)

at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)

at java.lang.Thread.run(Thread.java:923)

at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:393)

 

* 프로필 이미지 변경을 위해서 안드로이드 에뮬레이터 갤러리에 프로필로 선택 할 수 있는 사진이 필요함

  당연히 안드로이드 에뮬레이터에 업로드된 사진은 없는 상태

  인터넷에서 CROP하는 방법을 찾다가, 테스트만 할 수 있게 꼼수로 파일을 넣었다

   앱 만들기 강좌를 진행하는 것이 더 중요하니까 

   요정도 꼼수로 해보고 다음에 CROP으로 테스트 해 볼 것!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2020/08/02 - [경단녀에서 "나"로 돌아가기/안드로이드] - 안드로이드 에뮬레이터 갤러리에 사진 업로드 하는 방법(꼼수)

 

안드로이드 에뮬레이터 갤러리에 사진 업로드 하는 방법(꼼수)

외부 파일을 갤러리에 업로드하는 방법은 CROP 을 활용하여 해야 하고, * 프로그래밍막내님 블로그 참고! https://youngest-programming.tistory.com/54 [안드로이드] 갤러리 사진 불러오는 방법 + Crop 기능 이��

mongyeom.tistory.com

 

* Firebase Storage에 선택한 프로필 사진이 등록은 되지만 

메뉴에 프로필 이미지가 변경되지 않는 상태

하지만 Firebase 스토리지에는 사진이 정상적으로 변경된다

------------------------------ ProfileActivity Save() addOnSuccessListener 에서 로그인 성공시, 프로필 URL을 가져오는 부분에 메소드가 틀림

--------------------- 기존에 강의에서는 getDownloadUrl를 사용하고 있지만 이미 사용되지 않는 메소드이고

---------------------- 대체된 메소드로 URL을 가져올 경우 Uri 객체에 담아야 하는데 방법을 모름

-----------------------  찾아볼 것!!!!!!!!!!!!!!!!

downUri를 받아 올 수 있게 하여

프로필 수정시, 변경된 사진으로 보이지만

다시 로그인 했을 때, 기본 사진과 닉네임으로 보임

 

* getDownloadUrl 즉, Uri를 받아오는 방식이 변경됨

기존

Uri downloadUrl = taskSnapshot.getDownloadUrl();

변경

mountainsRef.getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {

@Override

public void onSuccess(Uri downloadUrl) {

ap.setProfileImage(downloadUrl.toString());

UserProfileChangeRequest profileUpdates = new UserProfileChangeRequest.Builder()

.setDisplayName(etNickname.getText().toString())

.setPhotoUri(downloadUrl)

.build();

user.updateProfile(profileUpdates)

.addOnCompleteListener(new OnCompleteListener<Void>() {

@Override

public void onComplete(@NonNull Task<Void> task) {

if (task.isSuccessful()) {

//성공

setResult(RESULT_OK);

finish();

Toast.makeText(ProfileActivity.this, "정상적으로 수정 되었습니다.", Toast.LENGTH_SHORT).show();

}else{

Toast.makeText(ProfileActivity.this, "오류가 발생했습니다. 잠시후 다시 해보세요.", Toast.LENGTH_SHORT).show();

}

pd.dismiss();

}

});

}

});

http://blog.naver.com/PostView.nhn?blogId=charlie0819&logNo=221945938406

 

[안드로이드]Firebase storage에 저장된 이미지url database에 저장하기

Firebase에 여러기능들이 있는데 그 중 storage는 이미지나 동영상 파일을 저장할 수 있는 곳입니다. url...

blog.naver.com

https://gist.github.com/jonathanbcsouza/13929ab81077645f1033bf9ce45beaab#comments

 

SOLUTION FOR: DEPRECATED >> Uri downloadUrl = taskSnapshot.getDownloadUrl

SOLUTION FOR: DEPRECATED >> Uri downloadUrl = taskSnapshot.getDownloadUrl - MainActivity.java

gist.github.com

https://firebase.google.com/docs/storage/android/upload-files?authuser=0

 

Android에서 파일 업로드  |  Firebase

Cloud Storage를 사용하면 Firebase가 제공하고 관리하는 Google Cloud Storage 버킷에 파일을 빠르고 손쉽게 업로드할 수 있습니다. 참고: 기본적으로 Cloud Storage 버킷에 파일을 업로드하려면 Firebase 인증을

firebase.google.com

Uri downloadUrl = taskSnapshot.getUploadSessionUri();//getDownloadUrl
//Task<Uri> downloadUrl = taskSnapshot.getMetadata().getReference().getDownloadUrl();
//Uri downLoadUrl = (Uri)taskSnapshot.getMetadata().getReference().getDownloadUrl();

W/Glide: Load failed for https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Fmong.jpg&uploadType=resumable&upload_id=AAANsUlv9dS8W03NVChu4NUtGuD55mU7hWpYUALWfnvGwYUqdjiEMuk7RwV1iCoVADdjhpBurWfgRNxj53JK5kH4DM6cNBjgyg&upload_protocol=resumable with size [175x175]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There was 1 cause:
java.io.FileNotFoundException(https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Fmong.jpg&uploadType=resumable&upload_id=AAANsUlv9dS8W03NVChu4NUtGuD55mU7hWpYUALWfnvGwYUqdjiEMuk7RwV1iCoVADdjhpBurWfgRNxj53JK5kH4DM6cNBjgyg&upload_protocol=resumable)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
There was 1 cause:
java.io.FileNotFoundException(https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Fmong.jpg&uploadType=resumable&upload_id=AAANsUlv9dS8W03NVChu4NUtGuD55mU7hWpYUALWfnvGwYUqdjiEMuk7RwV1iCoVADdjhpBurWfgRNxj53JK5kH4DM6cNBjgyg&upload_protocol=resumable)
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(https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Fmong.jpg&uploadType=resumable&upload_id=AAANsUlv9dS8W03NVChu4NUtGuD55mU7hWpYUALWfnvGwYUqdjiEMuk7RwV1iCoVADdjhpBurWfgRNxj53JK5kH4DM6cNBjgyg&upload_protocol=resumable)
call GlideException#logRootCauses(String) for more detail
Cause (1 of 1): class java.io.FileNotFoundException: https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Fmong.jpg&uploadType=resumable&upload_id=AAANsUlv9dS8W03NVChu4NUtGuD55mU7hWpYUALWfnvGwYUqdjiEMuk7RwV1iCoVADdjhpBurWfgRNxj53JK5kH4DM6cNBjgyg&upload_protocol=resumable
I/Glide: Root cause (1 of 1)
java.io.FileNotFoundException: https://firebasestorage.googleapis.com/v0/b/agmhealing3.appspot.com/o?name=profile%2Fmong.jpg&uploadType=resumable&upload_id=AAANsUlv9dS8W03NVChu4NUtGuD55mU7hWpYUALWfnvGwYUqdjiEMuk7RwV1iCoVADdjhpBurWfgRNxj53JK5kH4DM6cNBjgyg&upload_protocol=resumable
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:255)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:102)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:56)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:164)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:62)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:70)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:63)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:310)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:279)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:393)

 

*  프로필과 닉네임을 수정해서 저장하는 것은 성공 했으나, 수정 후 사용자 정보에 저장된 내용을 변경하는 부분이 없었음

  추가로 수정함.  소스 코드를 남겨 놓을 까 하다가 오틸라님이 공부하라고 남겨둔 여백인가 싶어서 생략한다

* 오틸라의 안드로이드 앱 만들기 강좌 : 힐링 #9

youtu.be/2GzDXaobTME

 

반응형