react-native app:compileDebugJavaWithJavac错误解决

本文介绍了在React Native项目中遇到的导入第三方库时的问题及解决办法。通过删除@Override注解和废弃的createJSModules方法,成功解决了编译错误。

今天在react native 中导入一个三方库,出现了这个问题react-native app:compileDebugJavaWithJavac

stackoverflow上找到了解决的办法,地址如下:

https://stackoverflow.com/questions/45580452/react-native-android-method-does-not-override-or-implement-a-method-from-a-supe

按照上面的意思是将@Override删除了,错误就goes away了。尝试了一下,还真的是。

接着看下面的回答,发现了这个

上图红框的意思是react native在0.47.0版本有一个突破性的改变breaking change,要移除未使用的createJSModules

也就是说,createJSModules已经用不到了,直接删除了(猜测,没去验证)。

 

=========----> 73% EXECUTING [4m 11s]id SDK Platform 23 in D:\AndroidDev\SDK\licenses License for package Android SDK Platform 23 accepted. Preparing "Install Android SDK Platform 23 (revision: 3)". "Install Android SDK Platform 23 (revision: 3)" ready. Installing Android SDK Platform 23 in D:\AndroidDev\SDK\platforms\android-23 > Task :react-native-mqtt:compileDebugJavaWithJavacished. > Task :react-native-mqtt:compileDebugJavaWithJavac FAILED Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.f :app:debugRuntimeClasspath > bcprov-jdk15on-1.54.jar > 815.3 KiB/3.1 MiB downloaded See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings 443 actionable tasks: 18 executed, 425 up-to-date Warning: This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times. D:\AwesomeProject\node_modules\react-native-mqtt\android\src\main\java\com\tuanpm\RCTMqtt\RCTMqttModule.java:29: ��� �: �Ҳ������� import com.facebook.react.LifecycleState; ^ ����: �� LifecycleState λ��: ����� com.facebook.react D:\AwesomeProject\node_modules\react-native-mqtt\android\src\main\java\com\tuanpm\RCTMqtt\RCTMqttPackage.java:26: ����: �������Ḳ�ǻ�ʵ�ֳ����͵ķ��� @Override ^ 2 ������ FAILURE: Build failed with an exception. > IDLE * What went wrong: Execution failed for task ':react-native-mqtt:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details. > :react-native-mqtt:compileDebugJavaWithJavac > Resolve files of :react-native-mqtt:debugCompileClasspath * Try: > Run with --stacktrace option to get the stack trace.-jdk15on-1.54.jar > 735.3 KiB/3.1 MiB downloaded > 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 6m 13s error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup. Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081 Warning: This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times. D:\AwesomeProject\node_modules\react-native-mqtt\android\src\main\java\com\tuanpm\RCTMqtt\RCTMqttModule.java:29: ��� �: �Ҳ������� import com.facebook.react.LifecycleState; ^ ����: �� LifecycleState λ��: ����� com.facebook.react D:\AwesomeProject\node_modules\react-native-mqtt\android\src\main\java\com\tuanpm\RCTMqtt\RCTMqttPackage.java:26: ����: �������Ḳ�ǻ�ʵ�ֳ����͵ķ��� @Override ^ 2 ������ FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':react-native-mqtt:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details. * 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 6m 13s at makeError (D:\AwesomeProject\node_modules\execa\index.js:174:9) at D:\AwesomeProject\node_modules\execa\index.js:278:16 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async runOnAllDevices (D:\AwesomeProject\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:109:5) at async Command.handleAction (D:\AwesomeProject\node_modules\@react-native-community\cli\build\index.js:192:9) info Run CLI with --verbose flag for more details.
08-15
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值