Is the claim reliable on Android or not?

there is this question and answer:

Can I use assert on Android devices?

However, I came across this:

http://tools.android.com/recent/androidstudio045released

which reads:

Some newer lint checks and in particular the checkbox use the assertion keyword. This does not work reliably on devices and you must use BuildConfig.DEBUG instead of conditional checks.

There is no "assertion" keyword, only the "assert" keyword, so I'm not sure what to even make from this release note.

Anyway, I'm curious:

If I follow the first link and do:

adb shell setprop debug.assert 1

      

before installing the app on a device and compiling the app as a debug version with assertions enabled, will they work reliably on all devices? Or, should I believe the release notes for Android Studio 0.4.5?

+3


source to share


2 answers


I think the difficulty is getting the job statements referenced by the lint checker. The workaround you are linking to is not officially supported and has recommended using conditional checks as the lint checker recommends.



The workaround for enabling assertions will only work for rooted devices and I don't know if 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 intended to support Dalvik.

+3


source


Assertions are unreliable on Android. There is no reliable mechanism in runtime to enable them, and developers continue to drop support. See Questions 175697 , 65183 , 36786 and 17324 .



To use operators reliably assert

, you have to translate your code , eg. before compiling it.

0


source







All Articles