在本机上升级gradle

时间:2019-09-17 07:11:17

标签: react-native gradle

自从我在Android Studio中升级Gradle组件以来,就无法编译React Native应用程序。 这是错误消息:

error React Native CLI uses autolinking for native dependencies, but the following modules are 
linked manually: 
  - react-native-gesture-handler (to unlink run: "react-native unlink react-native-gesture-handler")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going 
forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be 
included in your app automatically. If a library isn't compatible with autolinking, disregard this 
message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native- 
community/cli/blob/master/docs/autolinking.md
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" 
flag.
Jetifier found 919 file(s) to forward-jetify. Using 4 workers...
info JS server already running.
info Installing the app...

> Task :app:mergeDebugResources FAILED
[integer/react_native_dev_server_port] C:\projects\react-native-sample-with- 
redux\android\app\build\generated\res\resValues\debug\values\generated.xml  
[integer/react_native_dev_server_port] C:\projects\react-native-sample-with- 
redux\android\app\build\generated\res\resValues\debug\values\gradleResValues.xml: Error: Duplicate 
resources
[integer/react_native_inspector_proxy_port] C:\projects\react-native-sample-with- 
   redux\android\app\build\generated\res\resValues\debug\values\generated.xml     
[integer/react_native_inspector_proxy_port] C:\projects\react-native-sample-with- 
   redux\android\app\build\generated\res\resValues\debug\values\gradleResValues.xml: Error: 
Duplicate resources

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings
18 actionable tasks: 1 executed, 17 up-to-date

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> [integer/react_native_dev_server_port] C:\projects\react-native-sample-with- 
redux\android\app\build\generated\res\resValues\debug\values\generated.xml        
[integer/react_native_dev_server_port] C:\projects\react-native-sample-with- 
redux\android\app\build\generated\res\resValues\debug\values\gradleResValues.xml: Error: Duplicate 
resources
  [integer/react_native_inspector_proxy_port] C:\projects\react-native-sample-with- 
redux\android\app\build\generated\res\resValues\debug\values\generated.xml   
[integer/react_native_inspector_proxy_port] C:\projects\react-native-sample-with- 
redux\android\app\build\generated\res\resValues\debug\values\gradleResValues.xml: Error: Duplicate 
resources

如何升级应用中的Gradle设置,使其适合新的Gradle功能?

预先感谢

科比

1 个答案:

答案 0 :(得分:0)

React-native版本> 0.6,某些依赖项将自动链接,我们不需要使用react-native链接依赖项,但有些与自动链接不兼容,如下所示:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually:
  - react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons")
This is likely happening when upgrading React Native from below 0.60 to 0.60 or above. Going forward, you can unlink this dependency via "react-native unlink <dependency>" and it will be included in your app automatically. If a library isn't compatible with autolinking, disregard this message and notify the library maintainers.
Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.

直到现在,解决此问题的最佳方法是返回低于0.6的本地版本并重新安装。