본문 바로가기

Android

[Android/kotlin] java.lang.IllegalStateException: A migration from 1 to 2 was required but not found. 에러 해결

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 DB 버전을 올려주었다.

@Database(entities = [Song::class, User::class, Like::class, Album::class], version = 3)

 

그리고 다시 돌렸더니 제목과 같은

java.lang.IllegalStateException: A migration from 1 to 2 was required but not found.

이런 에러가 뜨고 앱을 삭제 후 재설치해도 같은 에러가 반복되었다.

 

결론은,

AndroidManifest 파일에서 AllowBackup=false로 바꿔주고 앱을 삭제했다가 깔았더니 되더라.

AllowBackup의 default 값이 true라서 앱을 지워도 저 백업 데이터가 남아있었기 때문에 DB의 업데이트에서 충돌이 난 듯 싶다.