根据项目需求需要集成支付宝支付
我使用的是 react-native-yunpeng-alipay
当根据文档在Android上集成的时候,运行时报错:如下:
/Users/abysskitty/Desktop/RNProject/KakouApp/node_modules/react-native-yunpeng-alipay/android/src/main/java/com/yunpeng/alipay/
AlipayPackage.java:25: 错误: 方法不会覆盖或实现超类型的方法
@Override ^ 1 个错误 :
react-native-yunpeng-alipay:compileReleaseJavaWithJavac FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failedfor task ':react-native-yunpeng-alipay:compileReleaseJavaWithJavac'. > Compilation failed; see the compiler error outputfor details. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED Total time:26.017 secs Could not install the app on the device, read the error abovefor details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html
在提示的错误中明确指出了
AlipayPackage.java:25: 错误: 方法不会覆盖或实现超类型的方法
@Override
^
1 个错误 :
react-native-yunpeng-alipay:compileReleaseJavaWithJavac FAILED
错误原因解析:因为在安卓中 @Override是复写父类的方法,而它的父类没有这个方法,所以不能复写。
解决办法:根据下面图片打开这个文件,注释掉报错的代码就好了。
这个错误其实就是这个 AlipayPackgae 实现的ReactPachger接口里没有注释掉的那个方法了,所以找不到就报错了。
网友评论