The implementation used to work fine, but then I upgraded gradle to 4.1.1 and i kept getting this error

Maybe this could help over CameraSource.java
@SuppressLint("Assert")
void release() {
assert (mProcessingThread == null || mProcessingThread.getState() == State.TERMINATED);
if (mDetector != null) {
mDetector.release();
mDetector = null;
}
}