yaaliuzhipeng / react-native-mlkit-translate-text

🧑‍🏫 machine learning translator for react native . based on Google MLKit.
16 stars 2 forks source link

Crash force close on Release APK Without Error for First Time Launch App Only #2

Closed putuoka closed 1 year ago

putuoka commented 1 year ago

I got my app suddenly force close when installing APK release for the first time only. When open it again for 2nd time it will running well no force close/crash after that.

i add the download language code in my splash screen here the code that make it force close

const DownloadLangModel = async () => {
    try {
      const [Ger, Indo, InIndia] = await Promise.all([
        MLKitTranslator.isModelDownloaded('GERMAN'),
        MLKitTranslator.isModelDownloaded('INDONESIAN'),
        MLKitTranslator.isModelDownloaded('HINDI'),
      ]);

      if (!Ger) {
        console.log('download model GERMAN');
        await MLKitTranslator.downloadModel('GERMAN');
      }

      if (!Indo) {
        console.log('download model INDONESIAN');
        await MLKitTranslator.downloadModel('INDONESIAN');
      }
      if (!InIndia) {
        console.log('download model HINDI');
        await MLKitTranslator.downloadModel('HINDI');
      }

      //props.navigation.replace('Main');
    } catch (error) {
      console.log(error);
    }
  };

  React.useEffect(() => {
    DownloadLangModel();
  }, []);

this is the command to build the APK release

./gradlew assembleRelease

APK release install on samsung galaxy tab s7 fe android 11

yaaliuzhipeng commented 1 year ago

I got my app suddenly force close when installing APK release for the first time only. When open it again for 2nd time it will running well no force close/crash after that.

i add the download language code in my splash screen here the code that make it force close

const DownloadLangModel = async () => {
    try {
      const [Ger, Indo, InIndia] = await Promise.all([
        MLKitTranslator.isModelDownloaded('GERMAN'),
        MLKitTranslator.isModelDownloaded('INDONESIAN'),
        MLKitTranslator.isModelDownloaded('HINDI'),
      ]);

      if (!Ger) {
        console.log('download model GERMAN');
        await MLKitTranslator.downloadModel('GERMAN');
      }

      if (!Indo) {
        console.log('download model INDONESIAN');
        await MLKitTranslator.downloadModel('INDONESIAN');
      }
      if (!InIndia) {
        console.log('download model HINDI');
        await MLKitTranslator.downloadModel('HINDI');
      }

      //props.navigation.replace('Main');
    } catch (error) {
      console.log(error);
    }
  };

  React.useEffect(() => {
    DownloadLangModel();
  }, []);

this is the command to build the APK release

./gradlew assembleRelease

APK release install on samsung galaxy tab s7 fe android 11

is it release error only ? have you reproduced it during dev time.

putuoka commented 1 year ago

is it release error only ? have you reproduced it during dev time.

Sorry i'm wrong. the issue is in prettier code formatting in vs code. my friend save the code from mac/ios, i'm dev on windows for android. the compile APK affected by this. it cause a crash. when i re-save all the project file one by one in my vs code it's working good. not sure what is happening why code formatter affect this crash. for now the issue has been resolve and not related to your repo. Thank you so much.