반응형
- 구현 코드
binding.ivPost.setImageBitmap(item.image)
- 상황
1. Android Room에 Bitmap 객체를 저장
2. 특정 페이지에서 저장한 Bitmap 객체를 가져오기
3. 구현 코드를 통해 ImageView에 표시 -- Error --
- 에러 내용 간략화 ( 접은글 상세 )
Canvas: trying to draw too large(243802848bytes) bitmap
더보기
Canvas: trying to draw too large(243802848bytes) bitmap
Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7675c69140 in tid 13016 (e.패키지), pid 13016 (e.패키지)
Cmdline: com.example.패키지
pid: 13016, tid: 13016, name: e.패키지 >>> com.example.패키지 <<<
#62 pc 000000000018fe74 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.appcompat.widget.AppCompatImageView.setImageDrawable+0)
#72 pc 000000000018fe4c [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.appcompat.widget.AppCompatImageView.setImageBitmap+0)
#77 pc 000000000000251c [anon:dalvik-classes7.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk!classes7.dex] (com.example.패키지.adapter.PostAdapter$ViewHolder.bind+0)
#82 pc 0000000000002778 [anon:dalvik-classes7.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk!classes7.dex] (com.example.패키지.adapter.PostAdapter.onBindViewHolder+0)
#87 pc 0000000000002758 [anon:dalvik-classes7.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk!classes7.dex] (com.example.패키지.adapter.PostAdapter.onBindViewHolder+0)
#92 pc 00000000002e7da0 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder+0)
#97 pc 00000000002e7be8 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder+0)
#102 pc 00000000002eba48 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline+0)
#108 pc 00000000002eb52c [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline+0)
#113 pc 00000000002eb118 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition+0)
#118 pc 00000000002eb0fc [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition+0)
#123 pc 00000000002e2434 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next+0)
#128 pc 00000000002e3ce4 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.LinearLayoutManager.layoutChunk+0)
#133 pc 00000000002e3620 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.LinearLayoutManager.fill+0)
#138 pc 00000000002e4164 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren+0)
#143 pc 00000000002f2138 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2+0)
#148 pc 00000000002f1df0 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView.dispatchLayout+0)
#153 pc 00000000002f342c [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.recyclerview.widget.RecyclerView.onLayout+0)
#169 pc 000000000021a374 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.constraintlayout.widget.ConstraintLayout.onLayout+0)
#207 pc 000000000021a374 [anon:dalvik-classes.dex extracted in memory from /data/app/~~uh4u5ME88NtKjDdilUiG9g==/com.example.패키지-Qzpft8BZ6aLtWW8n3yuNJA==/base.apk] (androidx.constraintlayout.widget.ConstraintLayout.onLayout+0)
- 해결
Room 에 @TypeConverter 을 이용하여 저장 및 불러올때의 문제로 아래 코드로 변경 후 해결
@TypeConverter
fun toByteArray(bitmap : Bitmap) : ByteArray = ByteArrayOutputStream().apply { bitmap.compress(Bitmap.CompressFormat.PNG, 100, this) }.toByteArray()
@TypeConverter
fun toBitmap(bytes : ByteArray) : Bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.size)
// @TypeConverter
// fun bitmapToJson(target: Bitmap) = Gson().toJson(target)
// @TypeConverter
// fun jsonToBitmap(target: String) = Gson().fromJson(target, Bitmap::class.java)
반응형
'오류 해결' 카테고리의 다른 글
[Android] MPAndroidChart Could not find com.github.PhilJay:MPAndroidChart:v3.1.0 해결 (0) | 2024.03.26 |
---|---|
[Android] 갤러리 사진 선택 - DecodeException: Input was incomplete (0) | 2023.12.12 |