question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error in firebase.mlkit.recognizeTextCloud: TypeError: Cannot read property 'android' of undefined

See original GitHub issue

Hi there,

When running the following code

onTextExtract() {
		firebase.mlkit.textrecognition.recognizeTextCloud({
			image: this.imageTaken, // a NativeScript Image or ImageSource, see the demo for examples
		})
		.then((result: MLKitRecognizeTextResult) => {
    	this.blocks = result.blocks;
		})
		.catch(errorMessage => console.log("ML Kit error: " + errorMessage));
	}

I am getting an error in the console log:

JS: Error in firebase.mlkit.recognizeTextCloud: TypeError: Cannot read property 'android' of undefined
JS: ML Kit error: TypeError: Cannot read property 'android' of undefined

I think the error come from src/mlkit/textrecognition/index.android.ts: 106 (come.google is undefined in com.google.android.gms.tasks.OnSuccessListener).

Thank you very much for you help.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
hgeller02commented, Jun 18, 2020

This response is pretty late and you have probably already found an answer, but here’s something that could help others who encounter the same issue. I did not solve the issue by removing another plugin. The property ‘android’ is actually part of NativeScript ImageSource, so this was probably set up incorrectly. Here is how to set it up correctly with TypeScript. First, you need to import ImageSource: import { ImageSource, fromFile } from "tns-core-modules/image-source";

Next, set your ImageSource to whatever image you want to scan using the firebase recognize text. This is just the path that I have for my project so this will look different for yours. let localImage: ImageSource = fromFile('~/assets/image/image.jpg');

And then put it into the text recognize method. Here’s what mine looks like for reference: private runTextRecognition(){ let localImage: ImageSource = fromFile('~/assets/image/scorecard1.jpg');

this.firebase.mlkit.textrecognition.recognizeTextOnDevice({ image: localImage }).then((result: MLKitRecognizeTextResult) => { console.log(result.text ? result.text : ""); }).catch(errorMessage => console.log("ML Kit error: " + errorMessage));

}

0reactions
MPerezMateocommented, Apr 2, 2020

Me too. Please report if you found the plugin interfering with this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

firebase cloud function error TypeError: Cannot read property ...
android - firebase cloud function error TypeError: Cannot read property 'child' of undefined - Stack Overflow. Collectives™ on Stack Overflow – ...
Read more >
Recognize Text in Images with ML Kit on Android - Firebase
This page describes an old version of the Text Recognition API, which was part of ML Kit for Firebase. The functionality of this...
Read more >
nativescript-firebase-updated-new - npm
Start using nativescript-firebase-updated-new in your project by running `npm i ... There are no other projects in the npm registry using ...
Read more >
Migrating for iOS | ML Kit - Google Developers
You can't mix frameworks and cocoapods, so in order to use this library you need to first migrate to use cocoapods. Update Cocoapods....
Read more >
Text Detector in Android using Firebase ML Kit - GeeksforGeeks
We have seen many apps that detect text from any image. This image may include number plates, images, and many more. In this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found