Cannot resolve symbol ReactApplication/ReactNativeHost

后端 未结 2 970
执笔经年
执笔经年 2021-01-04 07:44

I have a react native running perfectly on iOS but does not compile in Android studio due to import issues in MainApplication and MainActivity. I followed the React Native F

相关标签:
2条回答
  • 2021-01-04 08:06

    It happened to me too after detach my react-native project from Expo.

    In MainApplication I had "error Cannot resolve symbol" for these imports:

    import com.facebook.react.ReactApplication;
    import com.facebook.react.ReactNativeHost;
    

    in my package.json file I used:

    "react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",
    

    the problem was that the android can't find the directory for node_modules like that.

    in order to fix the issue I had to:

    1. change it to :

      "react-native": "^0.57.8",

    2. delete node_modules file

    3. run npm install
    4. delete .gradle folder from android project and sync project.

    That's what solved the problem for me. Hope I helped.

    0 讨论(0)
  • 2021-01-04 08:19

    I solved it by upgrading react-native, react-native-cli, gradle plugin to last version

    0 讨论(0)
提交回复
热议问题