Why Text to speech(TTS) object becomes null even after being initialized?How to make an Android Spinner with initial text “Select One”Text to speech(TTS)-AndroidGoogle Text-To-Speech APIView is null even after initializationWhy can I throw null in Java?Why is my Spring @Autowired field null?View.SurfaceView, why its member, mSurfaceHolder, returns null from getSurface()?Moshi's Custom Adapter with RxAndroid & Retrofit & KotlinMockito retrofit2 with MVP architectureRetrofit 2 - Getting response 200, but list is empty

"You are your self first supporter", a more proper way to say it

Intersection point of 2 lines defined by 2 points each

How much RAM could one put in a typical 80386 setup?

Do infinite dimensional systems make sense?

Definite integral giving negative value as a result?

Add text to same line using sed

Why doesn't H₄O²⁺ exist?

Why does Kotter return in Welcome Back Kotter?

How old can references or sources in a thesis be?

LaTeX: Why are digits allowed in environments, but forbidden in commands?

When a company launches a new product do they "come out" with a new product or do they "come up" with a new product?

Codimension of non-flat locus

Approximately how much travel time was saved by the opening of the Suez Canal in 1869?

Do I have a twin with permutated remainders?

Replacing matching entries in one column of a file by another column from a different file

Is it inappropriate for a student to attend their mentor's dissertation defense?

Does detail obscure or enhance action?

What does "Puller Prush Person" mean?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

Are astronomers waiting to see something in an image from a gravitational lens that they've already seen in an adjacent image?

Arrow those variables!

Which country benefited the most from UN Security Council vetoes?

How is it possible to have an ability score that is less than 3?

Can a Cauchy sequence converge for one metric while not converging for another?



Why Text to speech(TTS) object becomes null even after being initialized?


How to make an Android Spinner with initial text “Select One”Text to speech(TTS)-AndroidGoogle Text-To-Speech APIView is null even after initializationWhy can I throw null in Java?Why is my Spring @Autowired field null?View.SurfaceView, why its member, mSurfaceHolder, returns null from getSurface()?Moshi's Custom Adapter with RxAndroid & Retrofit & KotlinMockito retrofit2 with MVP architectureRetrofit 2 - Getting response 200, but list is empty






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm having trouble with ttsvariable . It becomes null, even if the Text to speech object has been initialized.



Inside ShowLabel() function, I want to use tts for texts of firstObject variable. ShowLabel() function receives a List<> of FirebaseVisionImageLabel objects. I'm facing problem on speaking the text inside ShowLabel(). Though the console logs the Boolean to true and the speak() inside OnInit() work.



I have set a checker ttsIsInitialized which is Boolean type, so it needs to be true before the speak() on showLabel() runs. But it gives me null. Any help would be great. If there is a best way to do this, please tell me.



So, For now my issue is tts inside Showlabel() always becomes null. Can someone point out where's my mistake?



This is a project on FirebaseQuickStart
https://github.com/firebase/quickstart-android/tree/master/mlkit



LivePreviewActivity



class LivePreviewActivity : AppCompatActivity(), OnRequestPermissionsResultCallback, TextToSpeech.OnInitListener {

private var cameraSource: CameraSource? = null
private var tts: TextToSpeech? = null
var firstObject = ""


override fun onCreate(savedInstanceState: Bundle?)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_live_preview)

tts = TextToSpeech(this, this)


fun showLabel(labels: List<FirebaseVisionImageLabel>?)
if (!ttsIsInitialized)
Log.d(TAG, "TTS not Initialized")
Log.d("Boolean", ttsIsInitialized.toString())
else
firstObject = labels!!.first().text
tts!!.speak(firstObject, TextToSpeech.QUEUE_FLUSH, null, "")
Log.d("Boolean", ttsIsInitialized.toString())



override fun onInit(status: Int)

if (status == TextToSpeech.SUCCESS) result == TextToSpeech.LANG_NOT_SUPPORTED)
Log.e("TTS","The Language specified is not supported!")
else
Log.d("TTS", "Initilization Successful")
tts!!.speak("This is a test", TextToSpeech.QUEUE_FLUSH, null, "")
cameraSource?.setMachineLearningFrameProcessor(ImageLabelingProcessor())
ttsIsInitialized = true

else
Log.e("TTS", "Initilization Failed!")





ImageLabelingProcessor



class ImageLabelingProcessor : VisionProcessorBase<List<FirebaseVisionImageLabel>>() 

private val detector: FirebaseVisionImageLabeler = FirebaseVision.getInstance().onDeviceImageLabeler

override fun stop()
try
detector.close()
catch (e: IOException)
Log.e(TAG, "Exception thrown while trying to close Text Detector: $e")



override fun detectInImage(image: FirebaseVisionImage): Task<List<FirebaseVisionImageLabel>>
return detector.processImage(image)


override fun onSuccess(
originalCameraImage: Bitmap?,
labels: List<FirebaseVisionImageLabel>,
frameMetadata: FrameMetadata,
graphicOverlay: GraphicOverlay
)
graphicOverlay.clear()
originalCameraImage.let image ->
val imageGraphic = CameraImageGraphic(graphicOverlay, image)
graphicOverlay.add(imageGraphic)

val labelGraphic = LabelGraphic(graphicOverlay, labels)
graphicOverlay.add(labelGraphic)
graphicOverlay.postInvalidate()

val livePreview = LivePreviewActivity()
livePreview.showLabel(labels)
livePreview.labels = labels


override fun onFailure(e: Exception)
Log.w(TAG, "Label detection failed.$e")


companion object
private const val TAG = "ImageLabelingProcessor"




Logcat



2019-03-09 14:54:50.979 9658-9658/com.google.firebase.samples.apps.mlkit E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.firebase.samples.apps.mlkit, PID: 9658
kotlin.KotlinNullPointerException
at com.google.firebase.samples.apps.mlkit.kotlin.LivePreviewActivity.showLabel(LivePreviewActivity.kt:76)
at com.google.firebase.samples.apps.mlkit.kotlin.imagelabeling.ImageLabelingProcessor.onSuccess(ImageLabelingProcessor.kt:51)
at com.google.firebase.samples.apps.mlkit.kotlin.imagelabeling.ImageLabelingProcessor.onSuccess(ImageLabelingProcessor.kt:19)
at com.google.firebase.samples.apps.mlkit.kotlin.VisionProcessorBase$detectInVisionImage$1.onSuccess(VisionProcessorBase.kt:98)
at com.google.android.gms.tasks.zzn.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2019-03-09 14:54:50.983 1881-1952/system_process W/ActivityManager: Force finishing activity com.google.firebase.samples.apps.mlkit/.kotlin.LivePreviewActivity
2019-03-09 14:54:50.997 9658-9658/com.google.firebase.samples.apps.mlkit I/Process: Sending signal. PID: 9658 SIG: 9
2019-03-09 14:54:51.004 1596-1596/? E/lowmemorykiller: Error writing /proc/9658/oom_score_adj; errno=22
2019-03-09 14:54:51.026 1712-9704/? E/Camera3-OutputStream: getBufferLockedCommon: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
2019-03-09 14:54:51.026 1712-9704/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)









share|improve this question
























  • is there any possibility that onInit() execute before OnCreate ?

    – NullPointerException
    Mar 9 at 5:00











  • @TejasPandya I'm not sure. Is there any way to see if it executes first? is it possible to delay the override function?

    – Ted Edwin
    Mar 9 at 5:57











  • Hi Ted! can you provide the logcat? Also, which code are you receiving from the listener? Finally, When are you executing showLabel() method? My guess is, since the API is asynchronous (synchronous APIs don't need listeners), you are executing the method before the listener is called, but since the listener is executed at some point, you see both the tts member as null, and the correct logs. Try executing showLabel inside the success block of onInit (AKA the listener)

    – Fco P.
    Mar 9 at 6:09











  • @TedEdwin please print message in your function and at run time check your log . in which sequence message has been printed

    – NullPointerException
    Mar 9 at 6:20











  • @FcoP. The tts inside the onInit() is working. just the on inside showLabel is null

    – Ted Edwin
    Mar 9 at 6:59


















0















I'm having trouble with ttsvariable . It becomes null, even if the Text to speech object has been initialized.



Inside ShowLabel() function, I want to use tts for texts of firstObject variable. ShowLabel() function receives a List<> of FirebaseVisionImageLabel objects. I'm facing problem on speaking the text inside ShowLabel(). Though the console logs the Boolean to true and the speak() inside OnInit() work.



I have set a checker ttsIsInitialized which is Boolean type, so it needs to be true before the speak() on showLabel() runs. But it gives me null. Any help would be great. If there is a best way to do this, please tell me.



So, For now my issue is tts inside Showlabel() always becomes null. Can someone point out where's my mistake?



This is a project on FirebaseQuickStart
https://github.com/firebase/quickstart-android/tree/master/mlkit



LivePreviewActivity



class LivePreviewActivity : AppCompatActivity(), OnRequestPermissionsResultCallback, TextToSpeech.OnInitListener {

private var cameraSource: CameraSource? = null
private var tts: TextToSpeech? = null
var firstObject = ""


override fun onCreate(savedInstanceState: Bundle?)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_live_preview)

tts = TextToSpeech(this, this)


fun showLabel(labels: List<FirebaseVisionImageLabel>?)
if (!ttsIsInitialized)
Log.d(TAG, "TTS not Initialized")
Log.d("Boolean", ttsIsInitialized.toString())
else
firstObject = labels!!.first().text
tts!!.speak(firstObject, TextToSpeech.QUEUE_FLUSH, null, "")
Log.d("Boolean", ttsIsInitialized.toString())



override fun onInit(status: Int)

if (status == TextToSpeech.SUCCESS) result == TextToSpeech.LANG_NOT_SUPPORTED)
Log.e("TTS","The Language specified is not supported!")
else
Log.d("TTS", "Initilization Successful")
tts!!.speak("This is a test", TextToSpeech.QUEUE_FLUSH, null, "")
cameraSource?.setMachineLearningFrameProcessor(ImageLabelingProcessor())
ttsIsInitialized = true

else
Log.e("TTS", "Initilization Failed!")





ImageLabelingProcessor



class ImageLabelingProcessor : VisionProcessorBase<List<FirebaseVisionImageLabel>>() 

private val detector: FirebaseVisionImageLabeler = FirebaseVision.getInstance().onDeviceImageLabeler

override fun stop()
try
detector.close()
catch (e: IOException)
Log.e(TAG, "Exception thrown while trying to close Text Detector: $e")



override fun detectInImage(image: FirebaseVisionImage): Task<List<FirebaseVisionImageLabel>>
return detector.processImage(image)


override fun onSuccess(
originalCameraImage: Bitmap?,
labels: List<FirebaseVisionImageLabel>,
frameMetadata: FrameMetadata,
graphicOverlay: GraphicOverlay
)
graphicOverlay.clear()
originalCameraImage.let image ->
val imageGraphic = CameraImageGraphic(graphicOverlay, image)
graphicOverlay.add(imageGraphic)

val labelGraphic = LabelGraphic(graphicOverlay, labels)
graphicOverlay.add(labelGraphic)
graphicOverlay.postInvalidate()

val livePreview = LivePreviewActivity()
livePreview.showLabel(labels)
livePreview.labels = labels


override fun onFailure(e: Exception)
Log.w(TAG, "Label detection failed.$e")


companion object
private const val TAG = "ImageLabelingProcessor"




Logcat



2019-03-09 14:54:50.979 9658-9658/com.google.firebase.samples.apps.mlkit E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.firebase.samples.apps.mlkit, PID: 9658
kotlin.KotlinNullPointerException
at com.google.firebase.samples.apps.mlkit.kotlin.LivePreviewActivity.showLabel(LivePreviewActivity.kt:76)
at com.google.firebase.samples.apps.mlkit.kotlin.imagelabeling.ImageLabelingProcessor.onSuccess(ImageLabelingProcessor.kt:51)
at com.google.firebase.samples.apps.mlkit.kotlin.imagelabeling.ImageLabelingProcessor.onSuccess(ImageLabelingProcessor.kt:19)
at com.google.firebase.samples.apps.mlkit.kotlin.VisionProcessorBase$detectInVisionImage$1.onSuccess(VisionProcessorBase.kt:98)
at com.google.android.gms.tasks.zzn.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2019-03-09 14:54:50.983 1881-1952/system_process W/ActivityManager: Force finishing activity com.google.firebase.samples.apps.mlkit/.kotlin.LivePreviewActivity
2019-03-09 14:54:50.997 9658-9658/com.google.firebase.samples.apps.mlkit I/Process: Sending signal. PID: 9658 SIG: 9
2019-03-09 14:54:51.004 1596-1596/? E/lowmemorykiller: Error writing /proc/9658/oom_score_adj; errno=22
2019-03-09 14:54:51.026 1712-9704/? E/Camera3-OutputStream: getBufferLockedCommon: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
2019-03-09 14:54:51.026 1712-9704/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)









share|improve this question
























  • is there any possibility that onInit() execute before OnCreate ?

    – NullPointerException
    Mar 9 at 5:00











  • @TejasPandya I'm not sure. Is there any way to see if it executes first? is it possible to delay the override function?

    – Ted Edwin
    Mar 9 at 5:57











  • Hi Ted! can you provide the logcat? Also, which code are you receiving from the listener? Finally, When are you executing showLabel() method? My guess is, since the API is asynchronous (synchronous APIs don't need listeners), you are executing the method before the listener is called, but since the listener is executed at some point, you see both the tts member as null, and the correct logs. Try executing showLabel inside the success block of onInit (AKA the listener)

    – Fco P.
    Mar 9 at 6:09











  • @TedEdwin please print message in your function and at run time check your log . in which sequence message has been printed

    – NullPointerException
    Mar 9 at 6:20











  • @FcoP. The tts inside the onInit() is working. just the on inside showLabel is null

    – Ted Edwin
    Mar 9 at 6:59














0












0








0








I'm having trouble with ttsvariable . It becomes null, even if the Text to speech object has been initialized.



Inside ShowLabel() function, I want to use tts for texts of firstObject variable. ShowLabel() function receives a List<> of FirebaseVisionImageLabel objects. I'm facing problem on speaking the text inside ShowLabel(). Though the console logs the Boolean to true and the speak() inside OnInit() work.



I have set a checker ttsIsInitialized which is Boolean type, so it needs to be true before the speak() on showLabel() runs. But it gives me null. Any help would be great. If there is a best way to do this, please tell me.



So, For now my issue is tts inside Showlabel() always becomes null. Can someone point out where's my mistake?



This is a project on FirebaseQuickStart
https://github.com/firebase/quickstart-android/tree/master/mlkit



LivePreviewActivity



class LivePreviewActivity : AppCompatActivity(), OnRequestPermissionsResultCallback, TextToSpeech.OnInitListener {

private var cameraSource: CameraSource? = null
private var tts: TextToSpeech? = null
var firstObject = ""


override fun onCreate(savedInstanceState: Bundle?)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_live_preview)

tts = TextToSpeech(this, this)


fun showLabel(labels: List<FirebaseVisionImageLabel>?)
if (!ttsIsInitialized)
Log.d(TAG, "TTS not Initialized")
Log.d("Boolean", ttsIsInitialized.toString())
else
firstObject = labels!!.first().text
tts!!.speak(firstObject, TextToSpeech.QUEUE_FLUSH, null, "")
Log.d("Boolean", ttsIsInitialized.toString())



override fun onInit(status: Int)

if (status == TextToSpeech.SUCCESS) result == TextToSpeech.LANG_NOT_SUPPORTED)
Log.e("TTS","The Language specified is not supported!")
else
Log.d("TTS", "Initilization Successful")
tts!!.speak("This is a test", TextToSpeech.QUEUE_FLUSH, null, "")
cameraSource?.setMachineLearningFrameProcessor(ImageLabelingProcessor())
ttsIsInitialized = true

else
Log.e("TTS", "Initilization Failed!")





ImageLabelingProcessor



class ImageLabelingProcessor : VisionProcessorBase<List<FirebaseVisionImageLabel>>() 

private val detector: FirebaseVisionImageLabeler = FirebaseVision.getInstance().onDeviceImageLabeler

override fun stop()
try
detector.close()
catch (e: IOException)
Log.e(TAG, "Exception thrown while trying to close Text Detector: $e")



override fun detectInImage(image: FirebaseVisionImage): Task<List<FirebaseVisionImageLabel>>
return detector.processImage(image)


override fun onSuccess(
originalCameraImage: Bitmap?,
labels: List<FirebaseVisionImageLabel>,
frameMetadata: FrameMetadata,
graphicOverlay: GraphicOverlay
)
graphicOverlay.clear()
originalCameraImage.let image ->
val imageGraphic = CameraImageGraphic(graphicOverlay, image)
graphicOverlay.add(imageGraphic)

val labelGraphic = LabelGraphic(graphicOverlay, labels)
graphicOverlay.add(labelGraphic)
graphicOverlay.postInvalidate()

val livePreview = LivePreviewActivity()
livePreview.showLabel(labels)
livePreview.labels = labels


override fun onFailure(e: Exception)
Log.w(TAG, "Label detection failed.$e")


companion object
private const val TAG = "ImageLabelingProcessor"




Logcat



2019-03-09 14:54:50.979 9658-9658/com.google.firebase.samples.apps.mlkit E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.firebase.samples.apps.mlkit, PID: 9658
kotlin.KotlinNullPointerException
at com.google.firebase.samples.apps.mlkit.kotlin.LivePreviewActivity.showLabel(LivePreviewActivity.kt:76)
at com.google.firebase.samples.apps.mlkit.kotlin.imagelabeling.ImageLabelingProcessor.onSuccess(ImageLabelingProcessor.kt:51)
at com.google.firebase.samples.apps.mlkit.kotlin.imagelabeling.ImageLabelingProcessor.onSuccess(ImageLabelingProcessor.kt:19)
at com.google.firebase.samples.apps.mlkit.kotlin.VisionProcessorBase$detectInVisionImage$1.onSuccess(VisionProcessorBase.kt:98)
at com.google.android.gms.tasks.zzn.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2019-03-09 14:54:50.983 1881-1952/system_process W/ActivityManager: Force finishing activity com.google.firebase.samples.apps.mlkit/.kotlin.LivePreviewActivity
2019-03-09 14:54:50.997 9658-9658/com.google.firebase.samples.apps.mlkit I/Process: Sending signal. PID: 9658 SIG: 9
2019-03-09 14:54:51.004 1596-1596/? E/lowmemorykiller: Error writing /proc/9658/oom_score_adj; errno=22
2019-03-09 14:54:51.026 1712-9704/? E/Camera3-OutputStream: getBufferLockedCommon: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
2019-03-09 14:54:51.026 1712-9704/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)









share|improve this question
















I'm having trouble with ttsvariable . It becomes null, even if the Text to speech object has been initialized.



Inside ShowLabel() function, I want to use tts for texts of firstObject variable. ShowLabel() function receives a List<> of FirebaseVisionImageLabel objects. I'm facing problem on speaking the text inside ShowLabel(). Though the console logs the Boolean to true and the speak() inside OnInit() work.



I have set a checker ttsIsInitialized which is Boolean type, so it needs to be true before the speak() on showLabel() runs. But it gives me null. Any help would be great. If there is a best way to do this, please tell me.



So, For now my issue is tts inside Showlabel() always becomes null. Can someone point out where's my mistake?



This is a project on FirebaseQuickStart
https://github.com/firebase/quickstart-android/tree/master/mlkit



LivePreviewActivity



class LivePreviewActivity : AppCompatActivity(), OnRequestPermissionsResultCallback, TextToSpeech.OnInitListener {

private var cameraSource: CameraSource? = null
private var tts: TextToSpeech? = null
var firstObject = ""


override fun onCreate(savedInstanceState: Bundle?)
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_live_preview)

tts = TextToSpeech(this, this)


fun showLabel(labels: List<FirebaseVisionImageLabel>?)
if (!ttsIsInitialized)
Log.d(TAG, "TTS not Initialized")
Log.d("Boolean", ttsIsInitialized.toString())
else
firstObject = labels!!.first().text
tts!!.speak(firstObject, TextToSpeech.QUEUE_FLUSH, null, "")
Log.d("Boolean", ttsIsInitialized.toString())



override fun onInit(status: Int)

if (status == TextToSpeech.SUCCESS) result == TextToSpeech.LANG_NOT_SUPPORTED)
Log.e("TTS","The Language specified is not supported!")
else
Log.d("TTS", "Initilization Successful")
tts!!.speak("This is a test", TextToSpeech.QUEUE_FLUSH, null, "")
cameraSource?.setMachineLearningFrameProcessor(ImageLabelingProcessor())
ttsIsInitialized = true

else
Log.e("TTS", "Initilization Failed!")





ImageLabelingProcessor



class ImageLabelingProcessor : VisionProcessorBase<List<FirebaseVisionImageLabel>>() 

private val detector: FirebaseVisionImageLabeler = FirebaseVision.getInstance().onDeviceImageLabeler

override fun stop()
try
detector.close()
catch (e: IOException)
Log.e(TAG, "Exception thrown while trying to close Text Detector: $e")



override fun detectInImage(image: FirebaseVisionImage): Task<List<FirebaseVisionImageLabel>>
return detector.processImage(image)


override fun onSuccess(
originalCameraImage: Bitmap?,
labels: List<FirebaseVisionImageLabel>,
frameMetadata: FrameMetadata,
graphicOverlay: GraphicOverlay
)
graphicOverlay.clear()
originalCameraImage.let image ->
val imageGraphic = CameraImageGraphic(graphicOverlay, image)
graphicOverlay.add(imageGraphic)

val labelGraphic = LabelGraphic(graphicOverlay, labels)
graphicOverlay.add(labelGraphic)
graphicOverlay.postInvalidate()

val livePreview = LivePreviewActivity()
livePreview.showLabel(labels)
livePreview.labels = labels


override fun onFailure(e: Exception)
Log.w(TAG, "Label detection failed.$e")


companion object
private const val TAG = "ImageLabelingProcessor"




Logcat



2019-03-09 14:54:50.979 9658-9658/com.google.firebase.samples.apps.mlkit E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.google.firebase.samples.apps.mlkit, PID: 9658
kotlin.KotlinNullPointerException
at com.google.firebase.samples.apps.mlkit.kotlin.LivePreviewActivity.showLabel(LivePreviewActivity.kt:76)
at com.google.firebase.samples.apps.mlkit.kotlin.imagelabeling.ImageLabelingProcessor.onSuccess(ImageLabelingProcessor.kt:51)
at com.google.firebase.samples.apps.mlkit.kotlin.imagelabeling.ImageLabelingProcessor.onSuccess(ImageLabelingProcessor.kt:19)
at com.google.firebase.samples.apps.mlkit.kotlin.VisionProcessorBase$detectInVisionImage$1.onSuccess(VisionProcessorBase.kt:98)
at com.google.android.gms.tasks.zzn.run(Unknown Source:4)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
2019-03-09 14:54:50.983 1881-1952/system_process W/ActivityManager: Force finishing activity com.google.firebase.samples.apps.mlkit/.kotlin.LivePreviewActivity
2019-03-09 14:54:50.997 9658-9658/com.google.firebase.samples.apps.mlkit I/Process: Sending signal. PID: 9658 SIG: 9
2019-03-09 14:54:51.004 1596-1596/? E/lowmemorykiller: Error writing /proc/9658/oom_score_adj; errno=22
2019-03-09 14:54:51.026 1712-9704/? E/Camera3-OutputStream: getBufferLockedCommon: Stream 0: Can't dequeue next output buffer: Broken pipe (-32)
2019-03-09 14:54:51.026 1712-9704/? E/Camera3-Device: RequestThread: Can't get output buffer, skipping request: Broken pipe (-32)






android kotlin nullpointerexception text-to-speech






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 6:58







Ted Edwin

















asked Mar 9 at 1:11









Ted EdwinTed Edwin

12




12












  • is there any possibility that onInit() execute before OnCreate ?

    – NullPointerException
    Mar 9 at 5:00











  • @TejasPandya I'm not sure. Is there any way to see if it executes first? is it possible to delay the override function?

    – Ted Edwin
    Mar 9 at 5:57











  • Hi Ted! can you provide the logcat? Also, which code are you receiving from the listener? Finally, When are you executing showLabel() method? My guess is, since the API is asynchronous (synchronous APIs don't need listeners), you are executing the method before the listener is called, but since the listener is executed at some point, you see both the tts member as null, and the correct logs. Try executing showLabel inside the success block of onInit (AKA the listener)

    – Fco P.
    Mar 9 at 6:09











  • @TedEdwin please print message in your function and at run time check your log . in which sequence message has been printed

    – NullPointerException
    Mar 9 at 6:20











  • @FcoP. The tts inside the onInit() is working. just the on inside showLabel is null

    – Ted Edwin
    Mar 9 at 6:59


















  • is there any possibility that onInit() execute before OnCreate ?

    – NullPointerException
    Mar 9 at 5:00











  • @TejasPandya I'm not sure. Is there any way to see if it executes first? is it possible to delay the override function?

    – Ted Edwin
    Mar 9 at 5:57











  • Hi Ted! can you provide the logcat? Also, which code are you receiving from the listener? Finally, When are you executing showLabel() method? My guess is, since the API is asynchronous (synchronous APIs don't need listeners), you are executing the method before the listener is called, but since the listener is executed at some point, you see both the tts member as null, and the correct logs. Try executing showLabel inside the success block of onInit (AKA the listener)

    – Fco P.
    Mar 9 at 6:09











  • @TedEdwin please print message in your function and at run time check your log . in which sequence message has been printed

    – NullPointerException
    Mar 9 at 6:20











  • @FcoP. The tts inside the onInit() is working. just the on inside showLabel is null

    – Ted Edwin
    Mar 9 at 6:59

















is there any possibility that onInit() execute before OnCreate ?

– NullPointerException
Mar 9 at 5:00





is there any possibility that onInit() execute before OnCreate ?

– NullPointerException
Mar 9 at 5:00













@TejasPandya I'm not sure. Is there any way to see if it executes first? is it possible to delay the override function?

– Ted Edwin
Mar 9 at 5:57





@TejasPandya I'm not sure. Is there any way to see if it executes first? is it possible to delay the override function?

– Ted Edwin
Mar 9 at 5:57













Hi Ted! can you provide the logcat? Also, which code are you receiving from the listener? Finally, When are you executing showLabel() method? My guess is, since the API is asynchronous (synchronous APIs don't need listeners), you are executing the method before the listener is called, but since the listener is executed at some point, you see both the tts member as null, and the correct logs. Try executing showLabel inside the success block of onInit (AKA the listener)

– Fco P.
Mar 9 at 6:09





Hi Ted! can you provide the logcat? Also, which code are you receiving from the listener? Finally, When are you executing showLabel() method? My guess is, since the API is asynchronous (synchronous APIs don't need listeners), you are executing the method before the listener is called, but since the listener is executed at some point, you see both the tts member as null, and the correct logs. Try executing showLabel inside the success block of onInit (AKA the listener)

– Fco P.
Mar 9 at 6:09













@TedEdwin please print message in your function and at run time check your log . in which sequence message has been printed

– NullPointerException
Mar 9 at 6:20





@TedEdwin please print message in your function and at run time check your log . in which sequence message has been printed

– NullPointerException
Mar 9 at 6:20













@FcoP. The tts inside the onInit() is working. just the on inside showLabel is null

– Ted Edwin
Mar 9 at 6:59






@FcoP. The tts inside the onInit() is working. just the on inside showLabel is null

– Ted Edwin
Mar 9 at 6:59













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073034%2fwhy-text-to-speechtts-object-becomes-null-even-after-being-initialized%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55073034%2fwhy-text-to-speechtts-object-becomes-null-even-after-being-initialized%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived