android / android/codelab-mlkit-android
lateinit property outputFileUri has not been initialized
- Dominant language
- Kotlin
- Stars
- 186
- Forks
- 104
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I am referring the tutorial of codelabs to work with ML Kit and at step 5 when I run the application I get the below error.
I tried to run the final module as well, faced the same issue.
```
Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {com.google.firebase.mlkit.codelab.objectdetection/com.google.firebase.mlkit.codelab.objectdetection.MainActivity}: kotlin.UninitializedPropertyAccessException: lateinit property outputFileUri has not been initialized
at android.app.ActivityThread.deliverResults(ActivityThread.java:4179)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3476)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3542)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2790)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1523)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6238)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:933)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)
Caused by: kotlin.UninitializedPropertyAccessException: lateinit property outputFileUri has not been initialized
at com.google.firebase.mlkit.codelab.objectdetection.MainActivity.getCapturedImage(MainActivity.kt:136)
at com.google.firebase.mlkit.codelab.objectdetection.MainActivity.onActivityResult(MainActivity.kt:84)
```
When I debug the app, I can see the var is initialized and the value is stored, but when at onactivityresult this exception is thrown.
any quick solution for the same would be great.
Contributor guide
Research direction
Start with MainActivity.kt, especially getCapturedImage at line 136 and onActivityResult at line 84, then reproduce the failure at codelab step 5 or in the final module. Trace the activity callback and outputFileUri state; done means the flow no longer raises UninitializedPropertyAccessException when the result is delivered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100