Android
[안드로이드 스튜디오] Execution failed for task ':app:checkDebugAarMetadata'
안드로이드 빌드 중 다음과 같은 오류가 발생했습니다. The minCompileSdk (32) 라고 적혀 있으므로 build.gradle에 가셔서 compileSdk와 targetSdk의 버전을 32로 바꿔주시면 됩니다. 저는 밑으로 쭉 내려보니 아래와 같은 오류도 발생했기에 compileSdk와 targetSdk를 33으로 바꿔주었습니다. 수정 후 Sync Now를 클릭해주시고 완료되면 빌드하시면 됩니다.
[안드로이드 스튜디오] Github 저장소 생성 & Android 프로젝트 연동/깃허브 토큰 로그인
Git 활성화 1) VCS -> Enable Version Control Integration 2) Git 선택 후 OK GitGub 계정 연동 1) File > Setting > Version Control > GitHub 2) Add Account 를 클릭하여 계정을 추가 3) 아래 화면 Authorize 버튼을 누르고 다음에 나오는 창에서도 Authorize 버튼을 눌러줍니다. 깃허브 계정을 입력해서 성공하면 끝 저는 계속 로그인이 되지 않았습니다. 찾아보니 Android Studio 버그라고 합니다. GitHub 토큰 로그인 이를 해결하기 위해 GitHub 토큰을 생성해서 연결해줍니다. GitHub 로그인 > Setting > Developer Settings > Personal access to..
[Kotlin] enum, sealed class
enum class - 같은 타입의 여러 상수 정의 - comma로 구분 enum class Color{ RED, GREEN, BLUE } enum class + When expression - else branch 없이도 모든 조건 평가 val colorCode = when(color){ Color.RED -> "#FF0000" Color.GREEN -> "#00FF00" Color.BLUE -> "#0000FF" } 1. 생성자, 프로퍼티 선언 가능 enum class Color(val rgb: Int){ RED(0xFF0000), GREEN(0x00FF00), BLUE(0x0000FF) } 2. 함수 선언 가능 enum class ProtocolState{ WAITING{ override fun s..
[Kotlin] 고차 함수, 람다, Scope functions
Functions types 1. (parameter) -> return type 파라미터 타입 선언 -> 리턴 타입 선언 (Int) -> Boolean (input: Int) -> Boolean (T) -> Boolean val isEven: (Int) -> Boolean = { it % 2 == 8 } 파라미터가 두개 이상일 때는 다음과 같다 (Int, Int) -> Int 파라미터명과 타입을 함께 작성할 수도 있다 (first: Int, second: Int) -> Int 2. with receiver - 함수 본문에 receiver 객체 참조 전달 .()는 this를 통해 참조(생략 가능) Int.() -> Boolean T.() -> R (마지막 줄 반환) val isEven: Int.() ->..
[Kotiln] Nested & inner class, Extension함수, Generics
Nested class / interface 1. 중첩된 클래스 class Outer { private val bar: Int = 1 class Nested { fun foo() = 2 } } val demo = Outer.Nested().foo() // == 2 Nested 클래스에서는 Outer 클래스의 프로퍼티나 함수에 접근 불가능 2. 중첩된 인터페이스 - 클래스 내부에 클래스나 인터페이스를 중첩하여 작성 가능 interface OuterInterface{ class InnterClass interface InnerInterface } class OuterClass{ class InnterClass interface InnterInterface } inner class 1. Outer 클래스의 멤..
[Kotlin] object
object 선언 object CartItems { private val mutableProducts = mutableListOf() val products: List = mutableProducts fun addProduct(product: Product){ mutableProducts.add(product) } } 싱글턴 패턴 - 전체에서 단일 객체로 유지하는 기법 - 인스턴스를 하나만 만들어 사용 object exrpessions - 무명 객체 1. 무명 객체 생성 - 이름을 생략하고 객체의 프로퍼티와 함수를 정의 - 단일 객체로 생성되는 것과 다르게 매번 새로운 객체를 생성 val cartItems object { val products = mutableListOf(Product("전자기기","핸..
[Kotlin] List, Set, Map, Collection Operations
Collections 1. List - ordered collection - index로 원소에 접근 가능 listOf(1,2,2) --> [1,2,2] 2. Set - unique elements setOf(1,2,2) ---> [1,2] 3. - key-value pairs - 동일한 key에 대해 하나의 value만 가짐 mapOf("first" to 1, "second" to 2, "second" to 3) --> {first=1, seconde=3} 4. Type 1) read-only val numbers = listOf("one", "two", "three", "four") 2) mutable - 순서를 가지며, 변경이 가능 val numbers = mutableListOf("one", "t..