안드로이드

[안드로이드] Firebase Realtime Database가 Release APK에서 작동하지 않는 문제 해결

start1a 2021. 4. 24. 15:51

Debug에서는 잘 작동하지만 Release로 실행할 경우에 에러가 발생했다.

원인

Release 버전으로 생성할 경우 Proguard가 미사용 코드를 삭제함
정확하진 않아 필요한 클래스도 삭제될 수 있음

해결

...

@IgnoreExtraProperties

@Keep

public class Posto {

        public String uid;

        public String nome;

...

 

제거되지 않도록 해당 클래스에 annotation을 붙임

 

build.gradle : app으로 이동하여

 

implementation 'com.android.support:support-annotations:28.0.0'

 

추가

 

 

stackoverflow.com/questions/47669621/firebase-realtime-database-does-not-retrieving-data-in-release-apk-android

 

Firebase realtime database does not retrieving data in release apk [Android]

The data retrieved perfectly when run the app on the device or emulator, but it is not showing the images when generate release apk I think the problem is due to proguard so I tried this answer h...

stackoverflow.com

https://developer.android.com/studio/build/shrink-code.html#keep-code

 

앱 축소, 난독화 및 최적화  |  Android 개발자  |  Android Developers

사용하지 않는 코드와 리소스를 삭제하기 위해 출시 빌드에서 코드를 축소하는 방법을 알아보세요.

developer.android.com