Facebook Android integration

Hi, I followed the steps from this post about general plugin integration

http://forums.coronalabs.com/topic/53286-about-corona-enterprise-plugins-configuration/?hl=%2Bfacebook+%2Benterprise+%2Bandroid

Few plugins work, but when Facebook plugin not. When I want to post to Facebook, app crashes with this log:

Any ideas?

Thanks!

W/dalvikvm(19410): threadid=1: thread exiting with uncaught exception (group=0x41677d40) W/System.err(19410): java.lang.NoClassDefFoundError: com.facebook.android.R$layout W/System.err(19410): at com.facebook.LoginActivity.onCreate(LoginActivity.java:57) W/System.err(19410): at android.app.Activity.performCreate(Activity.java:5248) W/System.err(19410): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110) W/System.err(19410): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2162) W/System.err(19410): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257) W/System.err(19410): at android.app.ActivityThread.access$800(ActivityThread.java:139) W/System.err(19410): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210) W/System.err(19410): at android.os.Handler.dispatchMessage(Handler.java:102) W/System.err(19410): at android.os.Looper.loop(Looper.java:136) W/System.err(19410): at android.app.ActivityThread.main(ActivityThread.java:5086) W/System.err(19410): at java.lang.reflect.Method.invokeNative(Native Method) W/System.err(19410): at java.lang.reflect.Method.invoke(Method.java:515) W/System.err(19410): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) W/System.err(19410): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) W/System.err(19410): at dalvik.system.NativeStart.main(Native Method) W/FlurryAgent(19410): Error logged: uncaught

I have the exact same error. 

I copy all the jar into my lib folder, and copy all the folders in res to my project’s res.

Able to build successfully, but getting this error.

same error too but don’t know why 

Per Engineering:

You should download the 3.18 version of the facebook SDK from: https://developers.facebook.com/resources/facebook-android-sdk-3.18.zip

since this is the version we tested against.

 

Then you should follow the steps here: http://developer.android.com/tools/projects/projects-cmdline.html#ReferencingLibraryProject

to reference the Facebook library.

 

After that you would only need to include the facebook.jar file and not the other jar/resource files.

 

Rob

Hi Rob,

  1. I used the Facebook sdks from the CoronaEnterprisePlugins.2015.2533 which is from the daily build corresponding with the Enterprise version. You mean we should use the facebook.jar build from the Facebook site other than the Corona site?

  2. It’s said the Facebook sdks has been implemented as the corona plugin(we could see that from the CoronaEnterprisePlugins), if we only include the Facebook.jar, does that mean we do not use the Facebook as the plugin but a native android library?

We asked Engineering to look at this thread, that was their response.   I can ask them for further clarification, but have you followed these instructions?

Thanks

Rob

  1. Not yet. 

In this post: http://forums.coronalabs.com/topic/53286-about-corona-enterprise-plugins-configuration/?hl=%2Bfacebook+%2Benterprise+%2Bandroid

@Joshua Quick told me should use the Facebook as a plugin now. But that way seems not working.

I’m confused  if we should download the Facebook sdk from the Facebook site, why there is the Facebook sdk in the CoronaEnterprisePlugins. Because I remembered in the Pro version, the Facebook indeed was changed to the plugin mode.

So I didn’t consider your ways before.

  1. I would to try your ways.

Actually the way you mentioned is used in the post http://forums.coronalabs.com/topic/51374-android-facebook-plugin-kills-app-on-api-call/ which answered by  dchan.

But in the post http://forums.coronalabs.com/topic/53286-about-corona-enterprise-plugins-configuration/

@Joshua Quick said 

"@coronaent, you are looking at old information.  Using the “project.properties” file to reference a library will only work if that library is set up as an “Android library project”… which contains other Android project related files and has a specific directory structure as documented by Google.  We used to distribute the facebook library like this, but not anymore.  The facebook library is now distributed as a plugin, meaning only its JAR files are res files are provided.  So, if you don’t have an Android library project folder to reference, then you have no choice but to copy the library’s *.jar files to your “libs” directory and its *.so files (if any) to your “libs/armeabi-v7a” directory.

 

Note that none of this is Corona related.  This is how Google’s Android SDK handles libraries.  I suggest that you review Google’s developer documentation here…

   https://developer.android.com/tools/projects/index.html#LibraryModules

 

So, for the current version of our facebook plugin (build #2430), you need to copy the following JAR files to your project’s “libs” directory:

  • facebook.jar

  • facebook._sdk.jar

  • android-support.jar

  • bolts-android-1.1.2.jar

 

Meaning, all JAR files for that plugin needed to be copied over.  You also must copy all of the plugin’s “res” files to your project’s “res” directory… maintain the same directory structure.

 

I also recommend that you look at the “metadata.lua” file to what permissions and XML elements need to be added to your project’s AndroidMainfest.xml file.  In facebook’s case, you need to add the 2 <activity> elements within the <application> block of your AndroidManifest.xml file."

 

 

That’s why I’m confused, different stuff give me the different answer. :frowning:

Just adding the libraries won’t generate the R.java file.  You need to reference the Facebook library for the R.java file to be generated.

So the files of Facebook in the CoronaEnterprisePlugins  is useless for the moment, right?

Which means I do not need them.

Yep. And please remember:

“After that you would only need to include the facebook.jar file and not the other jar/resource files.”

You must do that.

I have the exact same error. 

I copy all the jar into my lib folder, and copy all the folders in res to my project’s res.

Able to build successfully, but getting this error.

same error too but don’t know why 

Per Engineering:

You should download the 3.18 version of the facebook SDK from: https://developers.facebook.com/resources/facebook-android-sdk-3.18.zip

since this is the version we tested against.

 

Then you should follow the steps here: http://developer.android.com/tools/projects/projects-cmdline.html#ReferencingLibraryProject

to reference the Facebook library.

 

After that you would only need to include the facebook.jar file and not the other jar/resource files.

 

Rob

Hi Rob,

  1. I used the Facebook sdks from the CoronaEnterprisePlugins.2015.2533 which is from the daily build corresponding with the Enterprise version. You mean we should use the facebook.jar build from the Facebook site other than the Corona site?

  2. It’s said the Facebook sdks has been implemented as the corona plugin(we could see that from the CoronaEnterprisePlugins), if we only include the Facebook.jar, does that mean we do not use the Facebook as the plugin but a native android library?

We asked Engineering to look at this thread, that was their response.   I can ask them for further clarification, but have you followed these instructions?

Thanks

Rob

  1. Not yet. 

In this post: http://forums.coronalabs.com/topic/53286-about-corona-enterprise-plugins-configuration/?hl=%2Bfacebook+%2Benterprise+%2Bandroid

@Joshua Quick told me should use the Facebook as a plugin now. But that way seems not working.

I’m confused  if we should download the Facebook sdk from the Facebook site, why there is the Facebook sdk in the CoronaEnterprisePlugins. Because I remembered in the Pro version, the Facebook indeed was changed to the plugin mode.

So I didn’t consider your ways before.

  1. I would to try your ways.

Actually the way you mentioned is used in the post http://forums.coronalabs.com/topic/51374-android-facebook-plugin-kills-app-on-api-call/ which answered by  dchan.

But in the post http://forums.coronalabs.com/topic/53286-about-corona-enterprise-plugins-configuration/

@Joshua Quick said 

"@coronaent, you are looking at old information.  Using the “project.properties” file to reference a library will only work if that library is set up as an “Android library project”… which contains other Android project related files and has a specific directory structure as documented by Google.  We used to distribute the facebook library like this, but not anymore.  The facebook library is now distributed as a plugin, meaning only its JAR files are res files are provided.  So, if you don’t have an Android library project folder to reference, then you have no choice but to copy the library’s *.jar files to your “libs” directory and its *.so files (if any) to your “libs/armeabi-v7a” directory.

 

Note that none of this is Corona related.  This is how Google’s Android SDK handles libraries.  I suggest that you review Google’s developer documentation here…

   https://developer.android.com/tools/projects/index.html#LibraryModules

 

So, for the current version of our facebook plugin (build #2430), you need to copy the following JAR files to your project’s “libs” directory:

  • facebook.jar

  • facebook._sdk.jar

  • android-support.jar

  • bolts-android-1.1.2.jar

 

Meaning, all JAR files for that plugin needed to be copied over.  You also must copy all of the plugin’s “res” files to your project’s “res” directory… maintain the same directory structure.

 

I also recommend that you look at the “metadata.lua” file to what permissions and XML elements need to be added to your project’s AndroidMainfest.xml file.  In facebook’s case, you need to add the 2 <activity> elements within the <application> block of your AndroidManifest.xml file."

 

 

That’s why I’m confused, different stuff give me the different answer. :frowning:

Just adding the libraries won’t generate the R.java file.  You need to reference the Facebook library for the R.java file to be generated.

So the files of Facebook in the CoronaEnterprisePlugins  is useless for the moment, right?

Which means I do not need them.