Skip to content Skip to sidebar Skip to footer

Is Assert Reliable On Android Or Not?

there is this question and answer: Can I use assert on Android devices? However, then I ran across this: http://tools.android.com/recent/androidstudio045released which says: Some

Solution 1:

I think it's this difficulty getting assertions to work that the lint check is referring to. The workaround you linked to isn't officially supported, and it's recommended to use conditional checks as the lint check recommends.

The workaround to enable assertions will only work for rooted devices, and I don't know whether or not it will work on ART. There's more discussion at https://code.google.com/p/android/issues/detail?id=17324, the gist of which is that assertions were never really designed to be supported on Dalvik.

Solution 2:

Assertions are unreliable on Android. The runtime offers no reliable mechanism to enable them and the developers keep disavowing support. See issues 175697, 65183, 36786, and 17324.

To reliably use assert statements, you would have to translate the code, e.g. before compiling it.

Post a Comment for "Is Assert Reliable On Android Or Not?"