React Native:Android原生模块 [英] React Native: Android Native Module
问题描述
我在React Native / Android Project上实现了本机模块。
在android原生项目中,我使用startActivity函数移动到我手动创建的新活动。
我将分享一些代码。
I implemented native module on React Native / Android Project. In android native project, I used startActivity function to move to the new activity I created manually. I will share some of the codes.
//MainApplication.java
public class MainApplication extends MultiDexApplication {
...
// Needed for `react-native link`
public List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new AnExampleReactPackage(this)
);
}
...
}
在这里,如果我使用代码 new MainReactPackage()
然后我在Android设备上运行app时看到错误。
Here, if I use the code new MainReactPackage()
then I see the error while running app on my android device.
Native模块AccessibilityInfoModule试图覆盖模块名称AccessibilityInfo的
AccessibilityInfoModule。如果这是
你的意图,设置canOverrideExistingModule = true
Native module AccessibilityInfoModule tried to override AccessibilityInfoModule for module name AccessibilityInfo. If this was your intention, set canOverrideExistingModule=true
但我不确定如何设置 canOverrideExistingModule
。
如何解决这个问题?
But I'm not sure how I can set the canOverrideExistingModule
.
How can I solve this?
相对问题: React Native:Android活动返回
推荐答案
你真的想覆盖吗? AccessibilityInfoModule?如果是,那么只需将其添加到NativeModule类
Do you really want to override AccessibilityInfoModule? If yes then simply add this to your NativeModule class
@Override
public boolean canOverrideExistingModule() {
return true;
}
这篇关于React Native:Android原生模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!