Commit 7578e120 authored by Dan Jarvis's avatar Dan Jarvis
Browse files

Fix crash on closing the app when classifier failed to initialize

When testing on an API 21 emulator, the classifier fails to initialize.
`E/TfLiteCameraDemo: Failed to initialize an image classifier.`

In this situation, the app crashes when pressing Back to exit.  Here's the cause:
```
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.android.tflitecamerademo.ImageClassifier.close()' on a null object reference
                                                                                        at com.example.android.tflitecamerademo.Camera2BasicFragment.onDestroy(Camera2BasicFragment.java:331)
                                                                                        at android.app.Fragment.performDestroy(Fragment.java:2266)
```
The fix is to check for null before calling `.close()`.

I'll investigate why the classifier is failing to initialize separately. :-)
parent 766eb63f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment