stefalda / ReactNativeLocalization

Class to localize the ReactNative interface
MIT License
899 stars 124 forks source link

error Linking "react-native-localization" failed. Error: ENOENT: no such file or directory, open MainApplication.java #201

Closed dmontecillo closed 3 years ago

dmontecillo commented 3 years ago

info Linking "react-native-localization" Android dependency error Linking "react-native-localization" failed. Error: ENOENT: no such file or directory, open '\MainApplication. java' at Object.openSync (node:fs:505:3) at Object.readFileSync (node:fs:401:35) at applyPatch (\node_mo dules\@react-native-community\cli-platform-android\build\link\patches\applyPatch.js:42:5 1) at Object.registerNativeAndroidModule [as register] (\@react-native-community\cli-platform-android \build\link\registerNativeModule.js:34:27) at\node_modules\@react -native-community\cli\build\commands\link\linkDependency.js:63:16 at Array.forEach () at linkDependency (\nod e_modules\@react-native-community\cli\build\commands\link\linkDependency.js:36:32) at processTicksAndRejections (node:internal/process/task_queues:94:5) at async Object.link [as func] (\node_modules\@react-native-community\cli\build\commands\link\link.js:110:5) at async Command.handleAction (\node_modules\@react-native-community\cli\build\index.js:186:9)

Its looking for MainApplication.java and package name is correct as per my review 'com.mypackage.anotherpackage.MainApplication.java' but it seems like it couldn't complete the auto linker only for android

stefalda commented 3 years ago

Hi, try to create a new project because I don't think the problem is in this module.

Then install the library and replace the App.js with this code to detect if it's working:

import React from 'react';
import { Text, View } from 'react-native';
import LocalizedStrings from 'react-native-localization';

const strings = new LocalizedStrings({
  fr: { hello: "Halo" },
  en: { hello: "Hello" },
  it: { hello: "Ciao" }
});

const YourApp = () => {
  //strings.setLanguage("it");
  return (
    <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
      <Text>
        {strings.hello} come va
        {strings.getInterfaceLanguage()}
      </Text>
    </View>
  );
}

export default YourApp;