1
Resolved Questions / Re: Facebook
« on: July 08, 2013, 11:27:44 am »
I didn't write this...
Assuming you have created your facebook app and filled in all the correct data in the facebook developer website, you can continue to downloading the actual API and putting it somewhere you'll remember (preferably close to your project or haxe folders), extract everything from the zip file.
Now, create a file called 'include.nmml' at the root of the API folder with this code:
<?xml version="1.0" encoding="utf-8"?>
<project>
<java path="src" />
<java path="libs/android-support-v4.jar" />
</project>
And create a haxe file in that folder which will be responsible for all JNI communications (it's more comfortable to have one file responsible of all the operations).
And now you need to create the corresponding java file which will have all the functions called from JNI.
You also need to create a new MainActivity.java file for your app, which will include the full code from this tutorial (only the activity code is required):http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrump...
After you've created those files, you'll need to create the R.java file to put in src/com/facebook/android, which will be created from the facebook resources. You can create that file using aapt which can be found under your Android SDK folder, in platform-tools. Run the following command (where ANDROID_HOME is the location of your Android SDK folder, and DEV_HOME is the location of your project):
ANDROID_HOME/platform-tools/aapt
package
-v
-f
-m
-S DEV_HOME/res
-J DEV_HOME/src
-M DEV_HOME/AndroidManifest.xml
-I ANDROID_HOME/platforms/android-7/android.jar
More data about aapt can be found here:http://geosoft.no/development/android.html... and here:http://elinux.org/Android_aapt
You might also need to create the BuildConfig.java file if you don't have it, I have attached it. (you just need to change its extension because I couldn't upload it with the java extension)
Lastly, for the facebook folder, you need to go to the 'res\values' folder, and open the strings.xml file and add two lines:
<string name="app_name">NAME</string>
<string name="app_id">ID</string>
You can find your appID using the android keytool (make sure you have openssl installed) with the following command on windows:
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
and the following command on OS X:
[quotekeytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64][/quote]
Now, you also need to create a new AndroidManifest.xml file that will override the existing haxe one, so it will include the facebook activity. The correct AndroidManifest.xml file is attached (built using the template AndroidManifest.xml).
Now that you're done with all of that, go to your application's nmml file to include all the files that we've added.
Add the following lines (change the path to the correct path to your android facebook API files and all the other files you've added and change 'xxxxxxx', 'yyyyy' to be your correct package name):
<include path="../facebook-android" if="android" />
<template path="../facebook-android/res" rename="res" if="android" />
<template path="AndroidManifest.xml" if="android" />
<template path="../facebook-android/src/MainActivity.java" rename="src/com/xxxxxx/yyyyyyy/MainActivity.java" if="android" />
I can help you though.
Assuming you have created your facebook app and filled in all the correct data in the facebook developer website, you can continue to downloading the actual API and putting it somewhere you'll remember (preferably close to your project or haxe folders), extract everything from the zip file.
Now, create a file called 'include.nmml' at the root of the API folder with this code:
<?xml version="1.0" encoding="utf-8"?>
<project>
<java path="src" />
<java path="libs/android-support-v4.jar" />
</project>
And create a haxe file in that folder which will be responsible for all JNI communications (it's more comfortable to have one file responsible of all the operations).
And now you need to create the corresponding java file which will have all the functions called from JNI.
You also need to create a new MainActivity.java file for your app, which will include the full code from this tutorial (only the activity code is required):http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrump...
After you've created those files, you'll need to create the R.java file to put in src/com/facebook/android, which will be created from the facebook resources. You can create that file using aapt which can be found under your Android SDK folder, in platform-tools. Run the following command (where ANDROID_HOME is the location of your Android SDK folder, and DEV_HOME is the location of your project):
ANDROID_HOME/platform-tools/aapt
package
-v
-f
-m
-S DEV_HOME/res
-J DEV_HOME/src
-M DEV_HOME/AndroidManifest.xml
-I ANDROID_HOME/platforms/android-7/android.jar
More data about aapt can be found here:http://geosoft.no/development/android.html... and here:http://elinux.org/Android_aapt
You might also need to create the BuildConfig.java file if you don't have it, I have attached it. (you just need to change its extension because I couldn't upload it with the java extension)
Lastly, for the facebook folder, you need to go to the 'res\values' folder, and open the strings.xml file and add two lines:
<string name="app_name">NAME</string>
<string name="app_id">ID</string>
You can find your appID using the android keytool (make sure you have openssl installed) with the following command on windows:
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
and the following command on OS X:
[quotekeytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64][/quote]
Now, you also need to create a new AndroidManifest.xml file that will override the existing haxe one, so it will include the facebook activity. The correct AndroidManifest.xml file is attached (built using the template AndroidManifest.xml).
Now that you're done with all of that, go to your application's nmml file to include all the files that we've added.
Add the following lines (change the path to the correct path to your android facebook API files and all the other files you've added and change 'xxxxxxx', 'yyyyy' to be your correct package name):
<include path="../facebook-android" if="android" />
<template path="../facebook-android/res" rename="res" if="android" />
<template path="AndroidManifest.xml" if="android" />
<template path="../facebook-android/src/MainActivity.java" rename="src/com/xxxxxx/yyyyyyy/MainActivity.java" if="android" />
I can help you though.