RCTBatchedBridge.m 错误:无效的数据消息 - 全部长度必须为:%zd.React Native,iOS 模拟器 [英] RCTBatchedBridge.m Error: Invalid data message - all must be length:%zd. React Native, iOS simulator
问题描述
我正在使用 react-native-oauth
并在尝试授权时收到此错误(请参阅底部的红色图像).我搜索并发现只有这个
当我尝试提醒 config
对象时,我收到一个关于无法将其子对象字符串化的错误.
在 chrome 调试器中查看控制台时,我得到无法读取未定义的属性 'configureProvider'"并且 configureProvider()
是 react-native-oauth
使用的内容看起来经理设置不正确,所以也许我没有很好地链接库.已检查链接是否有效.
我正在深入研究这些错误,这似乎是 NativeModules.OAuthManager
中与承诺/回调相关的问题.捕获的错误是:TypeError:无法读取未定义的属性授权"
.当我跳入堆栈跟踪时,我发现:
非常感谢任何帮助,谢谢.
所以对我来说,无论出现什么问题,都是 react-native-oauth
的设置问题,因为自从我回滚到我的代码没有其他依赖项的程度(我还安装了 Firestack)并按照 react-native-oauth 的文档从头开始重新设置.我意识到我错过了 iOS/XCode 方面的一个步骤,因为当我最初尝试时我找不到文件,所以跳过了这一步:
接下来,导航到项目设置的相邻Build Phases"部分,找到Link Binary with Library"下拉菜单,将其展开,然后单击+"将 libOAuthManager.a 添加到列表中.
我得到的错误是从中删除了几步,但我确定以某种方式连接.经验教训:不要尝试一次做太多事情,也不要跳过必要的步骤.
I'm using react-native-oauth
and getting this error (see red image at bottom) when trying to authorise. I've searched and found only this similar unanswered question. I looked into the source and found where the error is raised on line 954 and it seems it's because moduleIDs.count
should equal methodIDs.count
and paramsArrays.count
:
if (RCT_DEBUG && (moduleIDs.count != methodIDs.count || moduleIDs.count != paramsArrays.count)) {
RCTLogError(@"Invalid data message - all must be length: %zd", moduleIDs.count);
So, still in the source, I look for these objects and find them defined just above, on lines 943-945 and they are using RCTConvert, whose functions "...all accept a JSON value as input and map it to a native Objective-C type or class." - React's docs
So it seems like this is a transpiling and/or networking related error. But I have basically 0 knowledge on those fields and feel I've hit a barrier to investigating and wondered if anybody had any ideas on moving forward. Being new to React Native and never having done any Objective-C can't be helping me.
Also, here's my code generating the errors.
import OAuthManager from 'react-native-oauth';
import {
Alert
} from 'react-native'
var env = require('../environment.js')
const config = {
facebook: {
client_id: env.getKey("FB_ID"),
client_Secret: env.getKey("FB_SECRET")
}
}
const manager = new OAuthManager('myAppName')
manager.configure(config);
exports.authWithFb = () => {
manager.authorize('facebook')
.then(resp => Alert.alert('response!' + resp))
.catch(err => Alert.alert('error msg here: ' + err));
}
I am guessing this undefined error is related to the RCTBridge error but not sure. You can below see when I Alert the manager.authorize
's caught error. TypeError: undefined is not an object (evaluating 'fn')
:
Edit:
When I try to Alert the config
object, I get an error about not being able to stringify it's sub-object.
When looking in console in chrome debugger, I get "Cannot read property 'configureProvider' of undefined" and configureProvider()
is what react-native-oauth
uses so it looks like the manager is not set up right so maybe I didn't link the library well. Have checked the linking worked.
Im digging into the errors a bit and it seems like a promise/callback related problem from NativeModules.OAuthManager
. The error caught is: TypeError: Cannot read property 'authorize' of undefined
. When I jump into the stack trace I find:
Any help is much appreciated, thanks.
So for me whatever was going wrong was a setup issue with react-native-oauth
because everything has fixed itself since I've rolled back to a point where my code had no other dependencies (I also had Firestack installed) and set up from scratch again following react-native-oauth's docs. I realised that there was a step on iOS/XCode's side that I had missed out because when I originally tried I couldn't find the file so just skipped that step:
From react-native-oauth readme
Next, navigate to the neighboring "Build Phases" section of project settings, find the "Link Binary with Library" drop down, expand it, and click the "+" to add libOAuthManager.a to the list.
The errors I were getting were a few steps removed from this but I'm sure connected somehow. Lessons learnt: don't try to do too many things at once and don't skip required steps.
这篇关于RCTBatchedBridge.m 错误:无效的数据消息 - 全部长度必须为:%zd.React Native,iOS 模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!