Android/이슈 처리

[Android] warning: Schema export directory is not provided ···

O_Gyong 2023. 4. 7.

warning: Schema export directory is not provided to the annotation processor so we cannot export the schema. You can either provide `room.schemaLocation` annotation processor argument OR set exportSchema to false.

 

위 경고 메시지는 Room 라이브러리를 사용해서 데이터베이스 스키마를 생성할 때 exportSchema 설정에 의해 위의 경고가 뜬다.

 

exportSchema는 Boolean 타입으로 데이터베이스 스키마를 폴더로 내보낼지 정할 수 있다.

default 값이 true로 되어있는데 폴더 경로를 정해줘야 한다.

경로를 정해주지 않으면 위의 경고가 발생하며, 경로를 설정하는 방법은 다음과 같다.

build.gradle(App)에서 defaultConfig 하위 섹션에 스키마 경로를 작성하면 된다.

android {
    ...
    
    defaultConfig {
        javaCompileOptions {
            annotationProcessorOptions {
                arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }
}

 

경로를 설정하고 싶지 않다면 옵션을 false로 두는 것으로 경고 문구를 피할 수 있다.

댓글