> For the complete documentation index, see [llms.txt](https://docs.tryterra.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tryterra.co/faq/help-topics/data-api-sdk/mobile-sdk-setup-permissions-and-crashes/android-release-proguard-r8-keep-rules.md).

# Why does the Flutter SDK fail in release but work in debug?

Code that works in debug but fails in Android release builds means **R8 minification (disabled in debug) is stripping or renaming SDK classes**. Add app-level ProGuard/R8 keep rules for the relevant Terra package and reference your `proguard-rules.pro` in the release `buildType`:

* Standard SDK: `-keep class co.tryterra.** { *; }`
* Real-time SDK: `-keep class co.tryterra.terrartandroid.** { *; }`

Gson 'abstract class can't be instantiated' crashes with obfuscated class names occur because Gson instantiates Terra model classes via reflection. Add the keep rule plus `-keepattributes Signature` and `Annotation`.

If you still see obfuscated names, your `proguard-rules.pro` is not being picked up:

* Confirm the release `buildType` references it.
* With Expo/EAS, run prebuild so `android/app/proguard-rules.pro` is applied.

If you use the direct Samsung Health integration, also keep Samsung's classes: `-keep class com.samsung.android.** { *; }`. Alternatively, disable minification for the release build. See the [Android setup docs](https://docs.tryterra.co/health-and-fitness-api/mobile-only-sources/android-kotlin) for more.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tryterra.co/faq/help-topics/data-api-sdk/mobile-sdk-setup-permissions-and-crashes/android-release-proguard-r8-keep-rules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
