JoeyEamigh / react-native-text-recognition

MIT License
23 stars 14 forks source link

java.lang.Double cannot be cast to java.lang.String and evaluating TextRecognition.recognize #1

Closed OmkoBass closed 2 years ago

OmkoBass commented 2 years ago

I created a clean react native project and i get this error when i use your package.

'java.lang.Double cannot be cast to java.lang.String'

I also got an error that says 'null is not an object ("evaluating TextRecognition.recognize'')'

App.js

import React, {useState, useEffect} from 'react';
import {SafeAreaView, StatusBar, Text, View} from 'react-native';
import TextRecognition from 'react-native-text-recognition';
import testImage from './src/assets/testImage.jpg';

const App = () => {
  const [text, setText] = useState('');

  useEffect(() => {
    (async () => {
      try {
        const result = await TextRecognition.recognize(testImage);

        setText(result);
      } catch (e) {
        console.log(e);
      }
    })();
  }, []);

  return (
    <SafeAreaView>
      <StatusBar />
      <View>
        <Text>Hello World</Text>
        <Text>{text}</Text>
      </View>
    </SafeAreaView>
  );
};

export default App;
JoeyEamigh commented 2 years ago

Is this on the ML branch or the main branch? Also, what is the photo?

OmkoBass commented 2 years ago

I'm using the main branch, i'll check out the ml branch now to see if it will work.

OmkoBass commented 2 years ago

I'm still getting the same error even on ML branch.

JoeyEamigh commented 2 years ago

What is the image you are using and what Android version? I've only tested Android 10 and 11.

OmkoBass commented 2 years ago

ext { buildToolsVersion = "30.0.2" minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30 ndkVersion = "21.4.7075529" }

The image is: https://ak.picdn.net/shutterstock/videos/1039447646/thumb/1.jpg

I think this is a version problem. Can you create a react native project that's working and i'll just fork it or something.

OmkoBass commented 2 years ago

Oh i get it, I should be using an image directly from the filesystem right? That's why it causes this problem most likely. Does this work with expo btw?

OmkoBass commented 2 years ago

Alright so, I was extremely dumb and used an asset from my vs code storage. What you should do is get an the file path from an actual image from your phone. Sorry for opening an issue for this, my bad.