[안드로이드 공부] 201

Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option

Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option viewModel 에 param을 추가하였더니 viewModel Factory가 필요하고, 추가 하니 위와 같은 에러가 나왔다~ 버전 충돌 문제인데~ build.gradle.app 에 kotlinOptions { jvmTarget = '1.8' freeCompilerArgs += [ '-Xjvm-default=enable' ] } 또는 tasks.withType(KotlinCompile).configureEach { kotlinOptions { freeCompilerArgs += [ "-Xjvm-default=all", ] } }..

Resource IDs will be non-final by default in Android Gradle Plugin version 8.0, avoid using them in switch case statements

switch 문에서 case R.id.xxxx 를 더 이상 제공 하지 않는다고 한다. 간단하게 if else 문으로 대체 하면 되는데 case 문이 많을 경우 난감하고 귀찮다. 이럴 때는 간단히 Refactoring 을 하면 된다. switch 에 커서를 올리고 Option(Windows Alt) + enter 를 치고 Replace switch with if 를 선택하면 한 방에 해결 된다.

bitbucket 계정 비밀번호(github 토큰) 설정 방법

Update failed Invocation failed Unexpected end of file from server java.lang.RuntimeException: Invocation failed Unexpected end of file from server Git 사용 시 이런 에러가 나타나면 앱 비밀번호를 생성 해주어야 한다 Github 에서는 토큰 생성하고, 메뉴에서 직접 입력 하면 되지만 Bitbucket에서는 안드로이드스튜디오 > Git > Manage Remote 주소 입력에 비밀번호를 넣어줘야 한다. https://계정:비밀번호@bitbucket.org/project 끝.

Gradle 7로 업그레이드 시 발생하는 에러 com.github.dcendents.android-maven

에러 문구 A problem occurred evaluating project Failed to apply plugin 'com.github.dcendents.android-maven'. Unable to load class 'org.gradle.api.publication.maven.internal.MavenPomMetaInfoProvider'. 주로, 오래된 오픈 소스를 사용하다 보면 발생하는 문제. 오픈소스의 그래들이 업데이트 되지 않기 때문데 아래와 같이 직접 수정 해주어야 한다. 모듈 gradle 수정 사항 아래와 같이 순서대로 수정 하면 된다. 1. 아래 줄 삭제 apply plugin: 'com.github.dcendents.android-maven' 하고 apply plugin: 'mave..

안드로이드 스튜디오 빌드 10% 향상 시키기

Build Analyzer 를 실행 하면 아래와 같이 팁이 나타나는데, 따라 해주면 10%의 성능 향상이 기대된다고 한다. gradle.properties 에 org.gradle.jvmargs=-Xmx2048m org.gradle.parallel=true 에서 아래 라인을 추가 -XX:+UseParallelGC 하면 org.gradle.jvmargs=-Xmx2048m -XX:+UseParallelGC org.gradle.parallel=true 요렇게 되고, Build Analyzer를 다시 실행하면 위 팁이 사라진다.

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.

안드로이드 스튜디오 버전이 올라가면서, Gradle 버전이 7로 올라가면서 자바 11로 올려줘야 하는 문제. > Failed to apply plugin 'com.android.internal.application'. > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of the following options: Mac 은 AndroidStudio > Preference Window는 File > Settings 간단하게 11로 변경만 해주면 완료 된다.

빌드 에러 - Attribute Signature requires InnerClasses attribute

Debug 모드에서 빌드되지만 Release 모드에서 빌드하면 다음과 같은 에러가 난다면? Build Output 에러 메시지 - Attribute Signature requires InnerClasses attribute 안드로이드 스튜디어 빌드 시 gradle 파일 release 모드에서 minifyEnabled true 가 되어 있으면 난독화 정보에 대해 proguard-rules.txt 파일을 참고합니다. 이 파일에 다음과 같은 구문을 적고 다시 빌드하면 됩니다. -keepattributes InnerClasses file이 없다면 app폴더 아래에 proguard-rules.txt 생성하세요.

LiveData 와 MutableLiveData

MutableLiveData는 Abstract Class 인 LiveData를 구현한 Public Class 위 말을 풀어 보면, 1. LiveData는 추상 클래스이므로 직접 생성할 수 없다. public abstract class LiveData { protected void postValue(T value) {} @MainThread protected void setValue(T value) {} //데이터 수정은 pretected 메서드를 구현해서 사용해야 한다. } val name : LiveData = LiveData() 위와 같이 직접 생성할 경우 아래와 같이 에러가 발생한다. cannot create an instance of an abstract class 반면에 MutableLiveDa..