Introducing new Facebook “v4a” plugin

Introducing new Facebook “v4a” plugin

Similar to the recent updates we made to the Google IAP plugin to help combat “App Not Responding” (ANR) reports in the Google Play console, we have released an updated Facebook v4a plugin to reduce the incidence of ANR errors. Here’s what you need to know…

Why a new updated plugin?

The last revision of the Facebook plugin begins initialization when you first require() it, and it does not return to the calling module until initialization is complete. On Android devices, this may appear (to Google) that the application isn’t responding, thus generating an ANR report.

To solve this, we have made the new Facebook v4a plugin asynchronous. The new process involves starting the initialization when you require the plugin, plus a new facebook.init() API to register a listener to be called when the initialization process completes.

Using the new plugin

To use the new plugin version, you need to do four things:

  1. Change your build.settings code to use the new plugin. Simply change "plugin.facebook.v4" to "plugin.facebook.v4a".
  2. Change any Lua file that requires the plugin to use the new plugin. Simply change require("plugin.facebook.v4") to require("plugin.facebook.v4a").
  3. Make sure you’re using Corona version 2017.3068 or later (2017.3068 is the most recent public release at the time of this writing).
  4. Following the first time you require() the plugin, likely within main.lua, add a call to facebook.init().

New initialization API

Since the new Facebook v4a plugin is asynchronous, you need to know when initialization is actually complete. Calling the new facebook.init() API gives you a chance to define a specific function which will be called when initialization completes. Once that function receives the "fbinit" event, you can safely call other Facebook API calls like facebook.publishInstall() or facebook.login() (although you should probably defer asking the player to log in until a point in your game which makes sense).

The listener function referenced in facebook.init() will also be used for other Facebook API calls to handle "fbconnect" events. Because of this, you only need to call facebook.setFBConnectListener() if you wish to use a different function to process your "fbconnect" events. See the integration documentation for more information and examples.


While this update only truly affects Android builds, you should follow similar behavior for iOS builds to maximize cross-platform compatibility. ANRs can be a silent error that you may never know about, so we strongly encourage you to update to the Facebook v4a plugin, especially if you have an active Android user base.

Rob Miracle

Rob is the Developer Relations Manager for Corona Labs. Besides being passionate about helping other developers make great games using Corona, he is also enjoys making games in his spare time. Rob has been coding games since 1979 from personal computers to mainframes. He has over 16 years professional experience in the gaming industry.

No Comments

Sorry, the comment form is closed at this time.