被断言可靠Android或不? [英] Is assert reliable on android or not?

查看:170
本文介绍了被断言可靠Android或不?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这个问题,答案是:

<一个href=\"http://stackoverflow.com/questions/2364910/can-i-use-assert-on-android-devices/5563637#5563637\">Can我主张用在Android设备上?

不过,后来我碰到这个跑:

http://tool​​s.android.com/recent/androidstudio045released

它说:


一些新的皮棉支票,并且其中标志使用断言关键字的特定的一个。这不会对设备可靠地工作,你应该使用BuildConfig.DEBUG做条件检查来代替。

有没有说法关键字,只有一个断言关键字,所以我不知道该怎么做,即使该版本说明。

不管怎样,我很好奇的是:

如果我按照第一个环节,做:

 亚行外壳setprop Debug.Assert的1

在设备上安装应用程序,并编译应用程序与调试断言开启之前,那么它们是可靠有望在所有设备上工作?或者,我应该相信为Android 0.4.5工作室?

发行说明
解决方案

我觉得这是这个困难得到断言的工作,皮棉检查是指。您链接到解决方法是不正式支持,并且它推荐为皮棉检查建议使用条件检查。

解决方法,以使断言将只根设备的工作,我不知道它是否会在艺术作品。还有更多的讨论在的https://$c$c.google .COM / p /安卓/问题/细节?ID = 17324 ,要点的就是一个说法是从来没有真正的设计上的Dalvik得到支持。

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 new lint checks, and in particular one which flags uses of the assertion keyword. This does not work reliably on devices and you should use BuildConfig.DEBUG to do conditional checks instead.

There is no "assertion" keyword, there is only an "assert" keyword, so I'm not sure what to even make of that release note.

Anyway, what I'm curious about is:

If I follow the first link and do:

adb shell setprop debug.assert 1

before installing the app on the device, and compile the app as debug with assertions turned on, then are they reliably expected to work on all devices? Or, should I believe the release notes for Android Studio 0.4.5?

解决方案

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.

这篇关于被断言可靠Android或不?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆