为调试APK和设备启用Java断言

时间:2013-11-06 15:50:03

标签: java android gradle android-studio android-gradle

我特别要求使用Gradle构建工具在最新版本的Android Studio中启用java断言。 linter建议在检测到潜在的NullPointerExceptions时使用它们,所以肯定是可能的。

以下代码在发生错误时起作用并抛出异常:

if (vehicleLocation == null) throw new IllegalStateException("vehicleLocation is null");

这不会抛出AssertionError,所以我假设它们没有打开。

assert vehicleLocation != null;

0 个答案:

没有答案