Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /
Prueba y depuración

Debugging - Java SDK

Importante

El depurador de Android Studio puede proporcionar valores erróneos para los campos del objeto Realm. Para obtener valores correctos, puede observar los valores de los descriptores de acceso o usar el objeto Realm. toString() Método para ver los últimos valores del campo.

This section details information you should keep in mind when debugging Realm applications with Android Studio to avoid incorrect value reporting. When you watch a Realm object, you'll see values displayed in the object's fields. These values are incorrect because the field values themselves are not used. This is because Realm creates a proxy object behind the scenes, overriding the getters and setters to access the persisted data in the realm. To see the correct values, add a watch on the accessors. See the image below:

When using the Android Studio debugger, accessors display the correct field value, while fields show outdated information.

In the image above, the debugger has stopped on line 113. There are three watch values:

  • La variable person

  • El acceso person.getName()

  • El acceso person.getAge()

The code from lines 107 to 111 alters the person instance by changing the name and age in a write transaction. On line 113, the person watch instance reports incorrect values for the field watch values. The watch values that use the accessors report values that are correct.

The Realm Java SDK library contains native code. Debugging NDK crashes can be cumbersome, as the default stack trace provides minimal information.

Le recomendamos que utilice una herramienta de informes de fallos como CrashlyticsEsto le permite rastrear errores nativos y recopilar información valiosa. Si cuenta con esta información, podemos ayudarle a solucionar sus problemas más rápidamente.

Para activar el reporte de fallos de NDK en Crashlytics para tu Proyecto, añade lo siguiente a la raíz de tu archivo de aplicación build.gradle:

crashlytics {
enableNdk true
}

Nota

Los valores androidNdkOut y androidNdkLibsOut no son necesarios.

Volver

Log Realm Events

En esta página