๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ“ฑ| Android/โœ… | ์—๋Ÿฌํ•ด๊ฒฐ9

[Android, Kotlin] Retrofit์—์„œ LocalDateTime ๋ฐ์ดํ„ฐ ๋ฐ›์•„์˜ค๊ธฐ 1. ์˜ค๋ฅ˜ ์ƒํ™ฉ retrofit์—์„œ localDateTime ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›์•„์˜ค๋˜ ์ค‘ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค. ์œ„์˜ ์˜ค๋ฅ˜๋Š” LocalDateTime parsing์—์„œ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒจ์„œ ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜์ด๋‹ค. ์ด ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ ํ•„์ž๋Š” ๊ฒ€์ƒ‰์„ ๊ธฐ๋ฐ˜์œผ๋กœ gson์— ๊ธฐ์กด์˜ localDatetime์„ parsing ํ•˜๋Š” ์ž‘์—…์˜ ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•˜์˜€๋‹ค. val gson = GsonBuilder() .setDateFormat("yyyy-MM-dd'T'HH:mm:ss") .create() return GsonConverterFactory.create(gson) ์œ„์˜ ๋ฐฉ๋ฒ•์€ ๋‚˜์—๊ฒŒ ์˜ฌ๋ฐ”๋ฅธ ๋ฐฉ๋ฒ•์ด ์•„๋‹ˆ์—ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ๋‚˜๋Š” ํ•œ ๋ธ”๋กœ๊ทธ์—์„œ ๋ฐฉ๋ฒ•์„ ์ฐพ์„ ์ˆ˜ ์žˆ์—ˆ๋‹ค. https://lemontia.tistory.com/997 [r.. 2023. 11. 6.
[Android, Kotlin] open api ์‚ฌ์šฉ ์ค‘ ๋ฐœ์ƒํ•œ java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.collections.CollectionsKt__IterablesKt.collectionSizeOrDefault, parameter <this> ํ•ด๊ฒฐ ๊ณต๊ณต๋ฐ์ดํ„ฐํฌํ„ธ api๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ณต๋ถ€๋ฅผ ํ•˜๋‹ค๊ฐ€ ๋˜(์˜ค)๋ฅ˜๋ฅผ ๋งŒ๋‚ฌ๋‹ค. ์˜ค๋ฅ˜์˜ ๋‚ด์šฉ์„ ๋ณด๋ฉด java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.collections.CollectionsKt__IterablesKt.collectionSizeOrDefault, parameter ๋Œ€์ถฉ ์–ด๋–ค ๋ฉ”์„œ๋“œ์˜ ๊ฐ’์ด null์ด๋ผ๋Š” ์˜ค๋ฅ˜ ๊ฐ™์•˜๋Š”๋ฐ httplogginginterceptor์—์„œ๋Š” api ๊ฒฐ๊ณผ๊ฐ€ ์ž˜ ๋‚˜์™”์—ˆ๋‹ค... ์•„๋ฌดํŠผ ํ•„์ž๊ฐ€ ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•œ ๋ฐฉ๋ฒ•์€ ํ•„์ž๋Š” api๋ฅผ ๋ฐ›์•„์˜ฌ data class์—๋‹ค๊ฐ€ @SerializedName์„ ์จ์„œ api์—์„œ ๋ฐ›์•„์˜ฌ ํ•„๋“œ๋ฅผ ์ •์˜ํ•ด ์คฌ์—ˆ๋Š”๋ฐ data class Body( @Serial.. 2023. 3. 21.
[Android, Kotlin] java.lang.RuntimeException: Parcelable encountered IOException writing serializable object ํ•ด๊ฒฐ ์˜ค๋žœ๋งŒ์— ํ•˜๋Š” ์˜ค๋ฅ˜ ํฌ์ŠคํŒ… ์˜ค๋ฅ˜ ๋‚ด์šฉ ์ด ์˜ค๋ฅ˜๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์€ data class์— ์žˆ๋‹ค. ์ € ์˜ค๋ฅ˜๋Š” ํ•„์ž๊ฐ€ putExtra๋ฅผ ์‚ฌ์šฉํ•ด ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๋ ค๊ณ  ํ–ˆ์„๋•Œ, ๋ฐœ์ƒํ•œ ์˜ค๋ฅ˜์˜€๋Š”๋ฐ ์˜ค๋ฅ˜์˜ ์ด์œ ๋ฅผ ๋ณด๋ฉด not serializable exception์ด๊ธฐ ๋•Œ๋ฌธ์— ํ•ด๋‹น ํด๋ž˜์Šค์— serializable์ด ์ ์šฉ์ด ์•ˆ๋˜์–ด์„œ ์˜ค๋ฅ˜๊ฐ€ ๋‚œ ๊ฒƒ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค. WeatherListResponse.kt package com.example.iwarm.data.response import com.google.gson.annotations.SerializedName import java.io.Serializable data class WeatherListResponse( @SerializedName("main") val mai.. 2022. 11. 28.
[Android, Kotlin] java.lang.ClassCastException: activity cannot be cast to interface ํ•ด๊ฒฐ ์˜ค๋Š˜์˜ ์˜ค๋ฅ˜๋Š” ํด๋ž˜์Šค ๊ฐ„์˜ ์บ์ŠคํŒ…์ด ์ž˜ ๋˜์ง€ ์•Š์•˜์„๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ์ธ ClassCastException์„ ํ•ด๊ฒฐํ–ˆ๋˜ ๊ณผ์ •์„ ํฌ์ŠคํŒ… ํ•ด๋ณด๊ฒ ๋‹ค. ์—๋Ÿฌ ๋ณธ๋ฌธ FreeBoardFragment 111๋ฒˆ์งธ ์ค„ override fun onAttach(context: Context) { super.onAttach(context) try { postImageData = activity as PostImageData } catch (e: ClassCastException) { Log.e("ERROR", e.printStackTrace().toString(), e.cause) } } interface๋ฅผ ์ด์šฉํ•ด fragment์—์„œ activity๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ „๋‹ฌํ•˜๋Š” ๊ณผ์ •์—์„œ onAttach ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋˜๋Š”๋ฐ, ์ด ๋ถ€๋ถ„์—.. 2022. 6. 7.
android.view.InflateException: Binary XML file line #15 in com.example.community:layout/activity_main: Binary XML file line #15 in com.example.community:layout/activity_main: Error inflating class TextView ์—๋Ÿฌ ํ•ด๊ฒฐ ์˜ค๋Š˜์˜ ์—๋Ÿฌ๋Š” view๊ฐ€ inflate๊ฐ€ ์ œ๋ฐ๋กœ ๋˜์ง€ ์•Š์•˜์„๋•Œ ์ƒ๊ธธ ์ˆ˜ ์žˆ๋Š” ์—๋Ÿฌ์ด๋‹ค. ๋‚˜๋Š” ๋ฌธ์ œ๊ฐ€ ์ƒ๊ธด textView์— theme๋ฅผ ๋งŒ๋“ค์–ด ์ ์šฉ์‹œ์ผœ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์—ˆ๋Š”๋ฐ, ๋ฌธ์ œ์˜ ํ…Œ๋งˆ ์ฝ”๋“œ textVIew์ธ๋ฐ theme์˜ parent๋ฅผ toolbar์˜ title๋กœ ์ง€์ •ํ•ด์„œ ์˜ค๋ฅ˜๊ฐ€ ๋‚˜๋Š” ๊ฑฐ์˜€๋‹ค. ํ•ด๊ฒฐํ•œ ํ…Œ๋งˆ ์ฝ”๋“œ parent๋ฅผ textView๋กœ ๋ฐ”๊ฟ”์ฃผ๋ฉด์„œ ๊ฐ„๋‹จํžˆ ํ•ด๊ฒฐํ–ˆ๋‹ค. ์“ธ๋ฐ์—†์ด 1์‹œ๊ฐ„์„ ๋‚ญ๋น„ํ–ˆ๋˜ ์˜ค๋ฅ˜์—ˆ๋‹ค. 2022. 4. 21.
java.lang.ClassNotFoundException: Didn't find class "com.example.community.MainActivity" ์˜ค๋Š˜์˜ ์—๋Ÿฌ๋Š” ๋ฐ”๋กœ ํด๋ž˜์Šค๋ฅผ ์ฐพ์„ ์ˆ˜ ์—†์„ ๋•Œ ๋œจ๋Š” ๋ฒ„๊ทธ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด๊ฒ ๋‹ค. ์—๋Ÿฌ ๋ฌธ๊ตฌ java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.community/com.example.community.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.community.MainActivity" on path: DexPathList[[zip file "/data/app/~~Tv8GPXV34ciClaHYGt-_Gg==/com.example.community-9AL2Z2ybv12CTGrbGEP6mQ==/base.a.. 2022. 4. 19.
Plugin [id: 'dagger.hilt.android.plugin'] was not found in any of the following sources ์ด๋ฒˆ ์˜ค๋ฅ˜๋Š” dagger hilt๋ฅผ ์“ฐ๋Š” ์‚ฌ๋žŒ๋“ค์—๊ฒŒ ๋‚˜ํƒ€๋‚ ์ˆ˜ ์žˆ๋Š” ์˜ค๋ฅ˜์ด๋‹ค ์˜ค๋ฅ˜ ๋ฌธ๊ตฌ * Exception is: org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'dagger.hilt.android.plugin'] was not found in any of the following sources: - Gradle Core Plugins (plugin is not in 'org.gradle' namespace) - Plugin Repositories (plugin dependency must include a version number for this source) at org.gradle.plugin.use.internal.DefaultPlugi.. 2022. 4. 18.
[Android] Room์—์„œ ๋ฐ์ดํ„ฐ ๋ฌด๊ฒฐ์„ฑ์„ ํ™•์ธํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ํ•„์ž๋Š” room์„ ์ด์šฉํ•œ ์˜ˆ์ œ๋ฅผ ๋งŒ๋“ค๋‹ค๊ฐ€ ํ•œ ์˜ค๋ฅ˜๋ฅผ ๋งŒ๋‚ฌ๋‹ค. ์˜ค๋ฅ˜ ์ฝ”๋“œ java.lang.IllegalStateException: Room cannot verify the data integrity. Looks like you've changed schema but forgot to update the version number. You can simply fix this by increasing the version number. ๋ฒˆ์—ญ์„ ํ•˜๋ฉด Room์—์„œ ๋ฐ์ดํ„ฐ ๋ฌด๊ฒฐ์„ฑ์„ ํ™•์ธํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์Šคํ‚ค๋งˆ๋ฅผ ๋ณ€๊ฒฝํ–ˆ์ง€๋งŒ ๋ฒ„์ „ ๋ฒˆํ˜ธ๋ฅผ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๊ฒƒ์„ ์žŠ์€ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋ฒ„์ „ ๋ฒˆํ˜ธ๋ฅผ ๋Š˜๋ฆฌ๋ฉด ๊ฐ„๋‹จํžˆ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋ผ๊ณ  ํ•ด์„œ ๋ฒ„์ „ ๋ฒˆํ˜ธ๋ฅผ ๋ฐ”๊ฟ”๋ณด์•˜๋‹ค. ๊ธฐ์กด ์ฝ”๋“œ @Database(entities = [UserE.. 2022. 4. 11.
[Android] com.google.gson.JsonParseException ํ•ด๊ฒฐ ์˜ค๋Š˜์€ ๋‚ด๊ฐ€ 5์‹œ๊ฐ„๋™์•ˆ ํ—ค๋ฉจ๋˜ ์˜ค๋ฅ˜์— ๋Œ€ํ•ด ํฌ์ŠคํŒ…์„ ๋‚จ๊ธฐ๊ฒ ๋‹ค. ๋‚˜๋Š” ๊นƒํ—ˆ๋ธŒ์— push ์‹ค์ˆ˜๋ฅผ ํ•ด์„œ ์–ด๋–ค ํŒŒ์ผ ํ•˜๋‚˜๋ฅผ git bash๋กœ ์‚ญ์ œํ–ˆ์—ˆ๋Š”๋ฐ... ๊ฐ‘์ž๊ธฐ ์•ˆ์Šค build gradle์ด ์•ˆ๋˜๋”๋‹ˆ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ์ƒ๊ฒผ๋‹ค ์ฒ˜์Œ์—๋Š” ๊ฒ€์ƒ‰์„ ํ•ด์„œ ํ•ด๊ฒฐํ•˜๋ ค ํ–ˆ์ง€๋งŒ ๊ฒ€์ƒ‰ํ•ด์„œ ๋‚˜์˜ค๋Š” ๋ฐฉ๋ฒ•๋“ค์ด ๋ชจ๋‘ ๋‚˜ํ•œํ…Œ๋Š” ์•ˆ ๋˜์„œ ํ˜ผ์ž ๋ง‰ ํ”„๋กœ์ ํŠธ ์„ค์ •์„ ๊ฑด๋“œ๋ฆฌ๋‹ค ์šฐ์—ฐํžˆ(?) ํ•ด๊ฒฐํ–ˆ๋‹ค. ํ•ด๊ฒฐ ๋ฐฉ๋ฒ• File -> Settings Settings์—์„œ gradle์„ ๊ฒ€์ƒ‰ํ•˜๋ฉด ์ด๋Ÿฐ ํ™”๋ฉด์ด ๋œฌ๋‹ค. ๊ทธ ๋‹ค์Œ gradle user home์˜ ์ฃผ์†Œ๋ฅผ ๋ฐ”๊ฟ”๋ณด์•˜๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ํ•ด๊ฒฐ์ด ๋๋‹ค. ์•„๋ฌดํŠผ ํ•ด๊ฒฐํ•˜๊ธด ํ–ˆ์œผ๋‚˜ ์ด๋ ‡๊ฒŒ ๊ฐ„๋‹จํžˆ ํ•ด๊ฒฐํ•ด์„œ ์•ฝ๊ฐ„ ํ˜„ํƒ€(?)๊ฐ€ ์™”์—ˆ๋‹ค.. 2022. 4. 3.
728x90