React-Native cannot find symbol after upgrade to 0.60

前端 未结 1 919
小鲜肉
小鲜肉 2021-01-11 18:02

I try to upgrade my react-native app 0.59.4 to 0.60.0.

I use this link as reference to upgrade all native files. But when I try to run my app on an Android device, I

相关标签:
1条回答
  • 2021-01-11 18:40

    I actually missed a few tiny things when using the same page as you did when I migrated from 0.59.10 to 0.60.0.

    One of the things I missed (which I could pinpoint was the problem in my case eventually) was that this section had to be added in the bottom of /android/app/build.gradle:

    apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
    

    I only had the similar line it in /android/settings.gradle but missed that one.


    There are other reasons why this might be happening too.
    Following are GitHub issues I found while trying to fix my project:

    • https://github.com/facebook/react-native/issues/9296: Clear the IDE caches and restart; didn't apply in my case but might do in yours.
    • https://github.com/facebook/react-native/issues/22033 Two solutions proposed:

      1. Make sure maven { url("$rootDir/../node_modules/react-native/android") } is in your allProjects.repositories in /android/build.gradle

      2. Explicitly set your react-native dependency to the version you use. So in /android/app/build.gradle in the dependencies section, you should find an entry compile "com.facebook.react:react-native:+. You can change that to compile "com.facebook.react:react-native:0.60.0. In some cases gradle used an old version of the library because it was referenced by some JavaScript dependency. This change should override that.

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