You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

React Native 0.60因自动生成PackageList致FBSDKPackage链接错误

Hey there, let's tackle this FBSDK error you're facing in React Native 0.60. I've dealt with this exact issue when React Native rolled out auto-linking, so let's break down what's happening and fix it step by step.

What's Causing the Error?

Looking at your code and the error message, the problem is clear:

  • The auto-generated PackageList class is creating a new FBSDKPackage() with no arguments.
  • But the FBSDKPackage constructor requires a CallbackManager instance (as seen in your manual initialization: new FBSDKPackage(mCallbackManager)).
  • On top of that, you're manually adding the FBSDK package again, which would lead to duplicate package registration even if the auto-linked version worked.

Step-by-Step Fix

1. Disable Auto-Linking for React Native FBSDK

Since auto-linking can't handle the custom constructor argument needed for FBSDK, we need to tell React Native to skip auto-linking this package.

Create or update a react-native.config.js file in your project root with this code:

module.exports = {
  dependencies: {
    'react-native-fbsdk': {
      platforms: {
        android: null, // Disable Android auto-linking
        ios: null      // Add this if you hit the same issue on iOS
      }
    }
  }
};

2. Clean Up Your MainApplication.java

Remove the risk of duplicate packages by keeping only your manual FBSDK initialization (the one with CallbackManager). Update your getPackages() method like this:

@Override
protected List<ReactPackage> getPackages() {
    @SuppressWarnings("UnnecessaryLocalVariable")
    List<ReactPackage> packages = new PackageList(this).getPackages();
    
    // Keep only this manual FBSDKPackage entry (with CallbackManager)
    packages.add(new FBSDKPackage(mCallbackManager));
    
    // Note: If RNGoogleSigninPackage is already in the auto-generated PackageList,
    // you can remove the line below to avoid duplicates
    packages.add(new RNGoogleSigninPackage());
    
    packages.add(new Interactable());
    return packages;
}

3. Clean and Rebuild Your Project

Old build artifacts might still have the broken auto-linked code, so let's clean and rebuild:
For Android:

cd android
./gradlew clean
cd ..
react-native run-android

Why This Works

By disabling auto-linking for FBSDK, we stop the invalid FBSDKPackage instance from being created in the auto-generated PackageList. Our manual initialization ensures the package gets the required CallbackManager, matching the constructor's requirements and resolving the error.

内容的提问来源于stack exchange,提问作者Tarun konda

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 09:13:24