坑啊!!!今天使用CameraRoll这个组件需要实现将图片保存到手机的需求,结果使用
yarn react-native run-android
运行的时候一切顺利,但当我开发完这个小需求后要打包的时候,却给我报了类似这个问题:
Error: /react-native-camera-roll/android/build/.transforms/934255b0981cee25c1088e05728c95ca/classes/classes.dex, Type com.reactnativecommunity./react-native-camera-roll.BuildConfig is defined multiple times: /Volumes/DATA/Development/Projects-github/Rejith UW/QubeMeetApp/Qubemeet/node_modules/react-native-webview/android/build/.transforms/934255b0981cee25c1088e05728c95ca/classes/classes.dex, /Volumes/DATA/Development/Projects-github/Rejith UW/QubeMeetApp/Qubemeet/android/app/build/intermediates/external_libs_dex/release/mergeExtDexRelease/classes3.dex
is defined multiple意味着被定义了多次,刚开始我还百思不得其解,我寻思我这代码在debug模式中运行正常啊,怎么到了release打包就打不了呢。之后我再
yarn react-native run-android
的时候发现大约的确也是报错了;也就是说在我安装完包后最好是要执行上面这句代码,直接yarn start 启动服务的话是不太科学的(可能)。
CameraRoll官网文档上找到了这一句!!!!
Notice: The NPM package name has changed, please change your package.json dependency!
Previous package name: @react-native-community/cameraroll
New package name: @react-native-camera-roll/camera-roll
真相大白!我去package.js里面找了 果然同时出现了cameraroll和camera-roll两个包名,之后我去掉@react-native-community/cameraroll在运行代码就一切正常了。
记录一下,折腾了我一个小时QAQ