안드로이드(kotlin)
-
[안드로이드 kotlin] unresolved reference: java안드로이드(kotlin)/에러 관련 2021. 9. 24. 11:26
unresolved reference: java 새로운 프로젝트를 시작하기 위해서 깃허브에서 내려받고 화면 전환하기 위해 Intent(this, MainActivity::class.java) 를 했는데 .java 부분이 빨간색으로 나타나네요. ktx-extensions 가 빠져서 그런줄 알고 gradle 에서 추가해줘봤지만 변동없었습니다. 혹시 버전이 문제가 아닐까 하는 생각에 implementation 'androidx.core:core-ktx:1.6.0' 버전을 기존에 작업했던 프로젝트에 맞춰서 1.3.2 로 변경해주고 sync now 하니까 빨간색이 사라졌습니다. 혹시 문제가 발생하신분들은 build.gradle(project) 에서 ext.kotlin_version 을 높이거나 낮추던지 build..
-
[안드로이드 kotlin]Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16.안드로이드(kotlin)/에러 관련 2021. 9. 8. 10:00
Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.16. 올해 초에 코틀린으로 프로젝트 끝낸 후 그 이후에 담당한 프로젝트는 자바로 개발하여 진행하였습니다. 그리고 이번에 새로운 프로젝트가 생겨서 코틀린으로 제작하려고 화면만 몇 개 넣고 빌드를 했는데 위와 같은 에러가 나타났습니다. 문제점을 찾아보니 버전이 안 맞는 문제 때문에 나타났던거였습니다. 기존의 코틀린 버전이 1.3.72를 사용중이었는데 모듈들만 업데이트 하다보니 호환성 문제를 나타내었던것이죠. 코틀린 버전을 업데이트 하고 project 단위 build.gradle ..
-
[안드로이드 kotlin] No static method metafactory error안드로이드(kotlin)/에러 관련 2021. 5. 17. 16:18
kotlin으로 retrofit 을 사용하려고 다 적용한 후 실행해보니 java.lang.NoSuchMethodError: No static method metafactory 라는 에러가 발생했습니다. 제대로 했는데 나타난 에러라서 구글에 찾아보니 자바 버전을 명시해주면 해결해준다고 찾았습니다. 출처는 아래와 같습니다. https://github.com/square/retrofit/issues/3280 java.lang.NoSuchMethodError: No static method metafactory · Issue #3280 · square/retrofit It seems the newest version implementation 'com.squareup.retrofit2:converter-scal..
-
[안드로이드 kotlin] 안드로이드 스튜디오 xml 디자인에서만 보이게 하기안드로이드(kotlin)/UI 2021. 5. 17. 12:02
xml 로 화면 작업을 하다보면 textview 에 글자를 숨겨서 표시해야 하는 경우 내용물을 다 지우거나 visible 을 사용합니다. 이렇게 하면 xml 에서도 표시가 되지 않게 됩니다. 디자인 화면상에만 표시하고 에뮬레이터나 실제 단말에서는 숨겨서 표시하고 싶은 경우도 있는데요 이럴때는 tools 를 이용하면 됩니다. 혹시 xml 의 최상위 layout 에 xmlns:tools="http://schemas.android.com/tools" 가 없다면 내용을 추가해주셔야 사용 가능합니다. 예시를 보여드릴게요. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 ..
-
[안드로이드 kotlin] 소프트 키보드 내리기(activity, custom dialog)안드로이드(kotlin)/기능 관련 2021. 5. 4. 09:59
EditText 를 사용하면 소프트 키보드를 이용하게 되는데 EditText 외에 다른곳을 누르면 소프트 키보드가 내려가도록 하려고 합니다. 코드는 간단합니다. 아래처럼 몇 줄만 넣으면 되죠. 1 2 3 4 5 6 @Override public boolean onTouchEvent(MotionEvent event) { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0); return true; } Colored by Color Scripter cs 자바 코드 1 2 3 4..
-
[android - kotlin] 색상 표현 방법안드로이드(kotlin)/UI 2021. 1. 2. 12:22
이미지뷰나 텍스트뷰 등에 색상을 변경하고 싶을 때 사용 방법 // resources.getColor 는 컬러만 지정하면 deprecated 경고 뜸. 이미지뷰.setBackgroundColor(resources.getColor(R.color.red, null)) // mContext 는 변수 생성을 해야 사용 가능. 이미지뷰.setBackgroundColor(ContextCompat.getColor(mContext, R.color.black)) // fragment 에서는 아래처럼 사용 가능. 이미지뷰.setBackgroundColor(ContextCompat.getColor(requireActivity().applicationContext, R.color.black)) // rgb 값을 이용한 색상 표..
-
[android - kotlin] error: incompatible types: IncludeServoLayoutBinding cannot be converted to ViewDataBinding setContainedBinding(this.mboundView11);안드로이드(kotlin)/에러 관련 2020. 12. 16. 11:51
error: incompatible types: IncludeServoLayoutBinding cannot be converted to ViewDataBinding setContainedBinding(this.mboundView11); 보여줄 레이아웃 fragment 는 fragment_hmi_servo.xml 이고, include 로 사용할 레이아웃은 include_servo_layout.xml 이었습니다. fragment_hmi_servo.xml 에는 ... 태그를 걸어주었습니다. 그리고 잘 될거라 생각되어 실행했습니다. 그랬더니 위와 같은 에러가 나타났습니다. 원인이 뭘까 찾아보다보니 databinding 을 사용한 레이아웃 안에 include 로 다른 레이아웃을 넣게 되면 그 레이아웃에도 ... ..
-
[android - kotlin] To use Coroutine features, you must add `ktx` artifact from Room as a dependency. androidx.room:room-ktx:<version>안드로이드(kotlin)/에러 관련 2020. 12. 14. 00:00
To use Coroutine features, you must add `ktx` artifact from Room as a dependency. androidx.room:room-ktx: build.gradle(Module: app) 의 dependencies 안에 kapt "androidx.room:room-compiler:$room_version" 만 추가해서 사용하다가 view model class안에 coroutine 을 사용하니까 위와같은 에러가 나타났습니다. 문제점이 뭔가 천천히 살펴보니 5번째 줄 가운데쯤에 error: 부분에 힌트가 있네요. room 과 관련된 ktx 가 필요하다는것 같습니다. developer.android 에서 해당 내용이 있는지 검색해봤습니다. developer.an..