본문 바로가기
Programming/Flutter

Flutter : FlutterSecureStorage 오류

by web data 2024. 6. 4.

Flutter : FlutterSecureStorage 를 사용하여 앱 개발 테스트 중 앱 재설치시 데이터를 삭제하지 않으면 앱 시작시 오류 발생
테스트 폰 : 삼성갤럭시S21(Android 13)

처리 1 (아래와 같이 옵션 추가)
final sStorage = const FlutterSecureStorage(
      aOptions: AndroidOptions(encryptedSharedPreferences: true));

 

해결된 듯 했으나,
삼성갤럭시노트10(Android 12)에서 비슷한 오류 발생 (위 S21의 경우 데이터 삭제 후 재설치하면 문제 없었으나, 이번에는 데이터를 삭제하고 재설치해도 동일한 문제 계속 발생)

 

에러 메세지 :

error: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT

 

처리 2 (AndroidManifest.xml 설정)

 

구글에서 이것저것 검색해보다 stackoverflow 에서 아래 내용 찾아 적용 (백업 관련 내용 두줄) : AndroidManifest.xml
(경로: 프로젝트 디렉토리 > android > app > src > main > AndroidManifest.xml)

<application
    .
    .
    .
    android:allowBackup="false"
    android:fullBackupContent="false"
    ...>