Android: Upgrade from 5.2.1 to 5.12.0 build error
Bug description:
When upgrading this package from 5.2.1 to 5.12.0 by using yarn upgrade [email protected], iOS works fine but Android has build errors. These are the errors:
Task :react-native-webview:compileDebugJavaWithJavac Note:
/node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /node_modules/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.
Task :react-native-webview:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug FAILED
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':react-native-webview:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug'. java.lang.RuntimeException: java.util.zip.ZipException: duplicate entry: com/reactnativecommunity/webview/events/TopLoadingErrorEvent.class
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 27s
I am using React Native version 0.57.8
To Reproduce:
- Upgrade react-native-webview via yarn from
5.2.1to5.12.0by usingyarn upgrade [email protected]. - Run
react-native run-android - See error as above
Expected behavior: Compiles app and runs in a simulator.
Environment:
- OS: Android
- OS version: Any
- react-native version: 0.57.8
- react-native-webview version: 5.12.0
请问你是如何解决的?
I'm encountering the same issue. Has it been closed by mistake?
cd ./android;./gradlew clean ;
你可以降低下webview的版本,因为版本会引起这个错误,cd ./android;./gradlew clean;这个命令可以解决现在这个错误,但是你如果要给项目添加新的组件的话,会再次出现这个错误,cd ./android;./gradlew clean;需要再次执行这个命令才会正常!