gpt4 book ai didi

android - 预期的动态类型 `double' ,但类型为 `null' (在索引 1 处为 Timing.createTimer 构造参数)

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:03:13 25 4
gpt4 key购买 nike

当我运行 react-native android 时,我一直收到此错误 Expected dynamic type `double', but had type `null' (Constructing arguments for Timing.createTimer at index 1)。当我尝试定位 Timing.createTimer 时,我发现它在 node_modules/react-native/Libraries/Core/Timers/JSTimers.js 内的 3 个地方使用:

1

setTimeout: function(
func: Function,
duration: number,
...args?: any
): number {
if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
console.warn(
ANDROID_LONG_TIMER_MESSAGE +
'\n' +
'(Saw setTimeout with duration ' +
duration +
'ms)',
);
}
const id = _allocateCallback(
() => func.apply(undefined, args),
'setTimeout',
);
Timing.createTimer(id, duration || 0, Date.now(), /* recurring */ false);
return id;
}

2

setInterval: function(
func: Function,
duration: number,
...args?: any


): number {
if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
console.warn(
ANDROID_LONG_TIMER_MESSAGE +
'\n' +
'(Saw setInterval with duration ' +
duration +
'ms)',
);
}
const id = _allocateCallback(
() => func.apply(undefined, args),
'setInterval',
);
Timing.createTimer(id, duration || 0, Date.now(), /* recurring */ true);
return id;
}

3

  requestAnimationFrame: function(func: Function) {
const id = _allocateCallback(func, 'requestAnimationFrame');
Timing.createTimer(id, 1, Date.now(), /* recurring */ false);
return id;
}

调用方法定义在JavaMethodWrapper.java 368行

   @Override
public void invoke(JSInstance jsInstance, ReadableNativeArray parameters) {
....
try {
for (; i < mArgumentExtractors.length; i++) {
mArguments[i] = mArgumentExtractors[i].extractArgument(
jsInstance, parameters, jsArgumentsConsumed);
jsArgumentsConsumed += mArgumentExtractors[i].getJSArgumentsNeeded();
}
} catch (UnexpectedNativeTypeException e) {
throw new NativeArgumentsParseException(
e.getMessage() + " (constructing arguments for " + traceName + " at argument index " +
getAffectedRange(jsArgumentsConsumed, mArgumentExtractors[i].getJSArgumentsNeeded()) +
")",
e);
}
....
}

它是从 JavaModuleWrapper.java 162

调用的
    @DoNotStrip
public void invoke(int methodId, ReadableNativeArray parameters) {
if (mMethods == null || methodId >= mMethods.size()) {
return;
}

mMethods.get(methodId).invoke(mJSInstance, parameters);
}

我尝试过的事情:

  1. 通过执行 if (id == null || id = '') { return null }
  2. 尝试在调用 Timing.createTimer 之前防止空 id
  3. 尝试打印在 Timing.createTimer 之前设置的 ID,但它导致应用停止响应,因为它几乎每秒都会触发

任何帮助将不胜感激。提前致谢

PS:我阅读了所有与此问题相关的帖子,但找不到适用的解决方案

最佳答案

您应该尝试此处的解决方案(有多种不同的解决方案适用于不同的用户): https://github.com/react-navigation/react-navigation/issues/2387

Figured out what my issue was, but it's odd as hell.. I only had a right chevron icon, so I applied a 180 degree rotate transform on it for my back button.. When I pressed on goBack, I had this same error: TypeError:expected dynamic type 'double',but had type 'string'.. If I remove the rotation transform everything works lol... Pretty odd..

关于android - 预期的动态类型 `double' ,但类型为 `null' (在索引 1 处为 Timing.createTimer 构造参数),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50614538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com