Trouble getting Facebook to work on Android build

My app builds ok, but when I test it on the device, I get the following error:

java.lang.NoClassDefFoundError: com.facebook.Settings

 

Looking at the logcat, here are the statements before the error:

I/dalvikvm(17929): Could not find method com.facebook.Session.getActiveSession, referenced from method com.ansca.corona.facebook.FacebookController.facebookLogin

W/dalvikvm(17929): VFY: unable to resolve static method 4144: Lcom/facebook/Session;.getActiveSession ()Lcom/facebook/Session;

D/dalvikvm(17929): VFY: replacing opcode 0x71 at 0x0013

I/dalvikvm(17929): Could not find method com.facebook.Session.getActiveSession, referenced from method com.ansca.corona.facebook.FacebookController.facebookLogout

W/dalvikvm(17929): VFY: unable to resolve static method 4144: Lcom/facebook/Session;.getActiveSession ()Lcom/facebook/Session;

D/dalvikvm(17929): VFY: replacing opcode 0x71 at 0x0000

I/dalvikvm(17929): Could not find method com.facebook.Session.getActiveSession, referenced from method com.ansca.corona.facebook.FacebookController.facebookRequest

W/dalvikvm(17929): VFY: unable to resolve static method 4144: Lcom/facebook/Session;.getActiveSession ()Lcom/facebook/Session;

D/dalvikvm(17929): VFY: replacing opcode 0x71 at 0x0007

I/dalvikvm(17929): Could not find method com.facebook.Settings.publishInstallAsync, referenced from method com.ansca.corona.facebook.FacebookController.publishInstall

W/dalvikvm(17929): VFY: unable to resolve static method 4155: Lcom/facebook/Settings;.publishInstallAsync (Landroid/content/Context;Ljava/lang/String;)V

D/dalvikvm(17929): VFY: replacing opcode 0x71 at 0x0004

D/dalvikvm(17929): DexOpt: unable to opt direct call 0x1023 at 0x25 in Lcom/ansca/corona/facebook/FacebookController;.facebookLogin

D/dalvikvm(17929): DexOpt: unable to opt direct call 0x102a at 0x35 in Lcom/ansca/corona/facebook/FacebookController;.facebookLogin

I/dalvikvm(17929): DexOpt: unable to optimize static field ref 0x0697 at 0x38 in Lcom/ansca/corona/facebook/FacebookController;.facebookLogin

I/dalvikvm(17929): Failed resolving Lcom/ansca/corona/facebook/FacebookController$FacebookEventHandler; interface 768 ‘Lcom/facebook/Session$StatusCallback;’

W/dalvikvm(17929): Link of class ‘Lcom/ansca/corona/facebook/FacebookController$FacebookEventHandler;’ failed

D/dalvikvm(17929): DexOpt: unable to opt direct call 0x0afd at 0x4b in Lcom/ansca/corona/facebook/FacebookController;.facebookLogin

I/dalvikvm(17929): Failed resolving Lcom/ansca/corona/facebook/FacebookController$FacebookEventHandler; interface 768 ‘Lcom/facebook/Session$StatusCallback;’

W/dalvikvm(17929): Link of class ‘Lcom/ansca/corona/facebook/FacebookController$FacebookEventHandler;’ failed

D/dalvikvm(17929): DexOpt: unable to opt direct call 0x0afd at 0x70 in Lcom/ansca/corona/facebook/FacebookController;.facebookLogin

D/dalvikvm(17929): DexOpt: unable to opt direct call 0x101e at 0x15 in Lcom/ansca/corona/facebook/FacebookController;.facebookRequest

I/dalvikvm(17929): Failed resolving Lcom/ansca/corona/facebook/FacebookController$FacebookRequestCallbackListener; interface 761 ‘Lcom/facebook/Request$Callback;’

W/dalvikvm(17929): Link of class ‘Lcom/ansca/corona/facebook/FacebookController$FacebookRequestCallbackListener;’ failed

D/dalvikvm(17929): DexOpt: unable to opt direct call 0x0b02 at 0x1a in Lcom/ansca/corona/facebook/FacebookController;.facebookRequest

I/Corona  (17929): Runtime error

I/Corona  (17929): java.lang.NoClassDefFoundError: com.facebook.Settings

I/Corona  (17929): Java Stack Trace:

I/Corona  (17929): com.ansca.corona.facebook.FacebookController.publishInstall(FacebookController.java:423)

I/Corona  (17929): com.ansca.corona.NativeToJavaBridge.callFBPublishInstall(NativeToJavaBridge.java:1997)

I/Corona  (17929): com.ansca.corona.JavaToNativeShim.nativeResize(Native Method)

I/Corona  (17929): com.ansca.corona.JavaToNativeShim.resize(JavaToNativeShim.java:381)

I/Corona  (17929): com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onSurfaceChanged(CoronaGLSurfaceView.java:374)

I/Corona  (17929): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1611)

I/Corona  (17929): com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

I/Corona  (17929): stack traceback:

I/Corona  (17929): [C]: in function ‘publishInstall’

I/Corona  (17929): ?: in main chunk

I uncommented out the section in AndroidManifest.xml concerning Facebook from the App project template. I also tried adding the following in the manifest file:

<meta-data android:name=“com.facebook.sdk.ApplicationId” android:value="@string/app_id"/>

and made the strings.xml file in the res/values folder.

The only thing our app uses right now is facebook.publishInstall.  I’m fairly new to Android native development, so I’m pretty sure I’m missing something obvious, but I can’t seem to find the right solution.

Thanks for any help.

Kenric

Are you using the Facebook SDK that came with the Enterprise package or did you download the SDK directly from Facebook?  I’m building a new app that is using Facebook.  It seemed like the version of the SDK was a bit out of date so I downloaded 3.17.1 directly from Facebook.  However what I found was that publishInstallAsync has been removed; I got the same runtime error as you.

From the Facebook release notes:


Upgrading the Android SDK from 3.15 to 3.16

The deprecated Settings.publishInstallAsync(), Settings.publishInstallAndWait(), and Settings.publishInstallAndWaitForResponse have been deleted. Use AppEventsLogger.activateApp() instead.


It looks like daily build 2014.2431 just changed the facebook integration for android so I’m going to update from 2428 and see if things are more up to date.

I updated to the latest Enterprise build and included the new FB android plug-in and it now works fine.

Are you using the Facebook SDK that came with the Enterprise package or did you download the SDK directly from Facebook?  I’m building a new app that is using Facebook.  It seemed like the version of the SDK was a bit out of date so I downloaded 3.17.1 directly from Facebook.  However what I found was that publishInstallAsync has been removed; I got the same runtime error as you.

From the Facebook release notes:


Upgrading the Android SDK from 3.15 to 3.16

The deprecated Settings.publishInstallAsync(), Settings.publishInstallAndWait(), and Settings.publishInstallAndWaitForResponse have been deleted. Use AppEventsLogger.activateApp() instead.


It looks like daily build 2014.2431 just changed the facebook integration for android so I’m going to update from 2428 and see if things are more up to date.

I updated to the latest Enterprise build and included the new FB android plug-in and it now works fine.