About Corona Enterprise plugins configuration

Please don’t post on this thread. Put all posts on the other thread please.

http://forums.coronalabs.com/topic/53394-facebook-android-integration/

Corona Enterprise for Android doesn’t use the “build.settings” file.  That file is for Corona Simulator builds.  You are expected to edit the AndroidManifest.xml, project.properties, and other Android project files yourself according to Google’s developer documentation.

Regarding plugins, you’ll need to add their libraries to your project yourself.  First, you’ll need to download our Corona plugins from our “Daily Builds”, which is listed under the “Corona Enterprise” tab.  You should download the plugins package matching the version of Corona Enterprise that you’re using…

   http://developer.coronalabs.com/downloads/daily-builds

You would then copy the plugin’s *.jar files to your project’s “libs” directory.

If the plugin uses *.so files, then those get copied to your project’s “libs/armeabi-v7a” directory.

If the plugin has a “res” directory, then copy those resources (while maintaining the subdirectory hierarchy) under your project’s “res” directory.

If the plugin includes a “metadata.lua”, then open it.  If it requires Android permissions then you’ll need to add them to your AndroidManifest.xml file youself according to Google’s documentation.  If it contains content under the “applicationChildElements” section, then that will need to be copy and pasted inside of your <application> tag within the AndroidManifest.xml file.

If you are new to native Android development, then I suggest you learn to use Google’s Android SDK development tools first by attempting to build Google’s sample project.  That will help you get familiarized with how to work in the native Android development environment.  It’ll also make the above plugin handling much clearer to you as well.  Here are some links to help you get started…

   https://developer.android.com/training/index.html

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

Thank you @Joshua, it’s helpful.

  1. I noticed there are ‘Resources/res’ under the facebook plugins but not ‘res’, that means I should copy the files of ‘Resources/res’ into the project’s ‘res’, right?

  2. But if there are more than one ‘Resources/res’ directories in different plugins, should I merge them into the one?

Yes, you’ll need to copy the contents of “Resources/res” to your project’s “res” directory.

And right again, you’ll need to merge all plugin resources into your “res” directory.  A simple copy and paste should be fine.  A plugin’s resource files are typically prefixed with a unique name to prevent file collision, such as “com_facebook*” for Facebook’s resources.  That’s standard practice for 3rd party Android libraries.

build successfully. But it crashed when run in the device.

Error log:

W/dalvikvm( 8469): threadid=1: thread exiting with uncaught exception (group=0x418b3ba8)

W/System.err( 8469): java.lang.NoClassDefFoundError: com.facebook.android.R$layout

W/System.err( 8469): at com.facebook.LoginActivity.onCreate(LoginActivity.java:57)

W/System.err( 8469): at android.app.Activity.performCreate(Activity.java:5231)

W/System.err( 8469): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

W/System.err( 8469): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)

W/System.err( 8469): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)

W/System.err( 8469): at android.app.ActivityThread.access

A “NoClassDefFoundError” exception indicates that the Java runtime failed to find the facebook library.

You’ll need to copy its *.jar files to your Android project’s “libs” directory.

I think I already done with the jar file.

Here is my directory list:

mac:libs willyma$ pwd

/Applications/CoronaEnterprise/Project/demo/android/libs

mac:libs willyma$ ls -l

total 3040

-rw-r–r--@ 1 willyma  staff    4967  7 16 17:00 CoronaProvider.analytics.flurry.jar

-rwxr-xr-x@ 1 willyma  staff  119449  7 16 17:00 FlurryAnalytics-4.1.0.jar

-rw-r–r--@ 1 willyma  staff  758727  9 13 17:00 android-support-v4.jar

-rw-r–r--@ 1 willyma  staff   46476  9 13 17:00 bolts-android-1.1.2.jar

-rw-r–r--@ 1 willyma  staff   33887 10 14 17:00 facebook.jar

-rw-r–r--@ 1 willyma  staff  514442  9 13 17:00 facebook_sdk.jar

-rw-r–r--@ 1 willyma  staff   59509 12  2 06:51 plugin.google.iap.v3.jar

I am having the same problem. From another thread, it suggested to add

android.library.reference.3=${CoronaEnterpriseDir}/Plugins/sdk-facebook/android

Not working, obviously, because the new Plugin is arrange like this:

${CoronaEnterpriseDir}/Plugins/facebook/2014.2430/android

So I change it to:

android.library.reference.3=${CoronaEnterpriseDir}/Plugins/facebook/2014.2430/android

And got this error:

/users/facv01/documents/coding/android/sdk/tools/ant/build.xml:577: ../../../../../../Applications/CoronaEnterprise/Plugins/facebook/2014.2430/android resolve to a path with no project.properties file for project /Users/facv01/Documents/Fundoma/jobr/android

Previously I successfully implement Facebook, with only paste facebook.jar in lib, and add reference in project.properties, no need to add res.

Help?

@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.

Hi @Joshua Quick, I think I’ve put the jars and res files to the right place as you said and build successfully.

But it still has the runtime crash when use Facebook related stuff.

I just didn’t figure it out. Need your help.

@mlhdyx, did you copy the relevant Android “metadata.lua” settings to your AndroidManifest.xml file like I mentioned up above?

There are 2 <activity> XML elements that need to be copied within your <application> block.

Hello,

I was having the same problem, where the “R” class was not found during runtime. Checking the generated files, the resource id that the facebook plugin was trying to access indeed did not existed in the R.java built during compilation.

The only way I managed to make the plugin work was by setting up a lib project with the “com.facebook.android” id and adding the jars and resources file to it.

It’ll definitely work if you copy facebook’s res files to your Android app project’s “res” directory too, because the Android SDK build effectively merges the 2 “res” directories anyways.  I do sometimes find that the Android SDK has “incremental build” issues.  Meaning that when you add/remove libraries or resources, Google’s Android build process doesn’t take hold of the change.  Google’s Eclipse ADT plugin is especially known to have this issue.

So, to solve this, you should do a “clean” build.

You can do this by typing “ant clean” in your Android app project directory via the Terminal.

Hi Joshua, I think I’ve done with them.

Please see the details: http://forums.coronalabs.com/topic/53843-facebook-crash-at-runtime-compiled-by-the-corona-enterprise/

I did the ‘ant clean’ too, but the problems are the same.

But now corona team has implemented the Facebook as a plugin, I think creating the lib project is for the old versions before.

@mlhdyx, Hi, mlhdyx. Did you solve this problem? I face the same problem. Can you tell me how to integrate Facebook library in details?

What I did is as below:

  1. copy all the jar files in Facebook plugin #2528 to my project libs folder

  2. copy res file to my project

  3. add meta data to Androidmanifest.xml

Is there any Corona stuff tell me what wrong with my project? Is there any steps I have missed?

Seems Facebook plugin from corona could not work currently, need to build with the origial Facebook lib sdks. 

Try to follow the infos in the http://forums.coronalabs.com/topic/53394-facebook-android-integration/#entry280250

It seems to me that there are two threads covering this topic.  Can we direct everyone here:

http://forums.coronalabs.com/topic/53394-facebook-android-integration/

Thanks

Rob

@Rob  Hi, Rob, Thanks, I read your topic. I notice that in this page:

http://docs.coronalabs.com/plugin/facebook/index.html

I follow the steps to download Facebook SDK 3.18 and reference Facebook library, but in the third step, I didn’t found the facebook.jar in the Facebook SDK 3.18.