EDIT: This has been worked out. But I will leave the original stuff rather than editing
everything.
So, again testing a very simple Android app to log in to Facebook and getting odd results.
The test app uses an app id that has been successfully (sort of) used to log in to Facebook (provided for testing by another developer).
// do the basic setup
FacebookSetup( "xxxxxxxxxxxx" ) // Here is my own appID
// start the login process (comment out and the Player doesn't crash)
FacebookLogin()
// check that the user has logged in
// check for a timeout in case there is a network problem
timeout# = timer() + 5.0
repeat
print("Logging in")
sync()
until GetFacebookLoggedIn() > 0 or timer() > timeout#
// get the login status
didlogin = GetFacebookLoggedIn()
// main loop
do
// allow a way to exit
if GetRawKeyPressed(27) then exit
if GetPointerPressed() then exit
print("")
print("Touch screen, back button or")
print(" escape key to exit")
print("")
if didlogin <= 0
// display error message
print("Could not log in to Facebook!")
else
// display connected message
print("Connected to Facebook!")
endif
sync()
loop
Let's start with the Player tests. I have two for v10818. One I built myself and the other downloaded from the 'My Products' TGC page.
With the downloaded one, the app starts, a facebooky looking sort of screen pops up and disappears (like it is trying to log in), then the screen goes black with the text "Please Wait..." in the middle and it hangs there. Touching the back button takes me back to the app and it says that it could not log in.
With my home built Player (and I've never had issues doing my own ones before), as soon as it tries the FacebookLogin() command, it crashes with the message "Unfortunately, v10818 Player has stopped". I had started this Player from Eclipse, so was able to catch the LogCat output.
Here is the output just before and after the crash:
09-02 16:51:23.684: I/native-activity(5023): Gained Focus
09-02 16:51:23.694: I/threaded_app(5023): SaveInstanceState: 0x682458c0
09-02 16:51:23.704: I/native-activity(5023): Save State
09-02 16:51:23.704: I/threaded_app(5023): APP_CMD_SAVE_STATE
09-02 16:51:23.704: I/threaded_app(5023): Pause: 0x682458c0
09-02 16:51:23.704: I/threaded_app(5023): activityState=13
09-02 16:51:23.704: I/native-activity(5023): App Paused
09-02 16:51:23.714: W/dalvikvm(5023): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 16:51:23.714: W/dalvikvm(5023): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 16:51:23.714: W/dalvikvm(5023): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 16:51:23.714: W/dalvikvm(5023): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 16:51:23.714: I/dalvikvm(5023): Could not find method android.support.v4.content.LocalBroadcastManager.getInstance, referenced from method com.facebook.Session.postActiveSessionAction
09-02 16:51:23.714: W/dalvikvm(5023): VFY: unable to resolve static method 270: Landroid/support/v4/content/LocalBroadcastManager;.getInstance (Landroid/content/Context;)Landroid/support/v4/content/LocalBroadcastManager;
09-02 16:51:23.714: D/dalvikvm(5023): VFY: replacing opcode 0x71 at 0x0009
09-02 16:51:23.724: W/dalvikvm(5023): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 16:51:23.724: W/dalvikvm(5023): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 16:51:23.734: D/AndroidRuntime(5023): Shutting down VM
09-02 16:51:23.734: W/dalvikvm(5023): threadid=1: thread exiting with uncaught exception (group=0x41ede930)
09-02 16:51:23.734: E/AndroidRuntime(5023): FATAL EXCEPTION: main
09-02 16:51:23.734: E/AndroidRuntime(5023): java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
09-02 16:51:23.734: E/AndroidRuntime(5023): at com.facebook.Session.postActiveSessionAction(Session.java:1341)
09-02 16:51:23.734: E/AndroidRuntime(5023): at com.facebook.Session.setActiveSession(Session.java:841)
09-02 16:51:23.734: E/AndroidRuntime(5023): at com.thegamecreators.agk_player.MyFacebookActivity.onCreate(MyFacebookActivity.java:39)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.app.Activity.performCreate(Activity.java:5104)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.os.Handler.dispatchMessage(Handler.java:99)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.os.Looper.loop(Looper.java:137)
09-02 16:51:23.734: E/AndroidRuntime(5023): at android.app.ActivityThread.main(ActivityThread.java:5041)
09-02 16:51:23.734: E/AndroidRuntime(5023): at java.lang.reflect.Method.invokeNative(Native Method)
09-02 16:51:23.734: E/AndroidRuntime(5023): at java.lang.reflect.Method.invoke(Method.java:511)
09-02 16:51:23.734: E/AndroidRuntime(5023): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-02 16:51:23.734: E/AndroidRuntime(5023): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-02 16:51:23.734: E/AndroidRuntime(5023): at dalvik.system.NativeStart.main(Native Method)
I ran similar code in Tier 2 (based on my own template):
// Includes, namespace and prototypes
#include "template.h"
using namespace AGK;
app App;
/////////////////////////////////////////
// PROTOTYPES ///////////////////////////
/////////////////////////////////////////
#ifdef IDE_ANDROID
extern void exit(int);
#endif
// facebook test
int curr_state = 0;
float timeout;
bool logged = false;
/////////////////////////////////////////
// CLASS IMPLEMENTATION /////////////////
/////////////////////////////////////////
// Begin app, called once at the start
void app::Begin( void )
{
// assume okay for now
did_end = false;
// set color and sync rate
agk::SetClearColor(0,0,153);
agk::SetSyncRate(60.0f,0);
// set a default resolution (for portrait iPhone)
agk::SetVirtualResolution(640,960);
// allow all orientations
agk::SetOrientationAllowed(1,1,1,1);
// start Facebook setup
agk::FacebookSetup("500636119972722");
}
// Main loop, called every frame
void app::Loop ( void )
{
// check for ended, it means that we have
// nothing displaying and don't want to
// fun afoul of Sync() looking for non-existent things
if (app::did_end) return;
// if pointer pressed, we are done
if (agk::GetPointerPressed()) closeThisApp();
// display something
agk::Print("Touch/click anywhere to exit.\n\n");
agk::Print("");
agk::PrintC("FPS: ");
agk::Print(agk::ScreenFPS());
// facebook test
// process state
switch(curr_state)
{
case 0:
// start login
agk::FacebookLogin();
curr_state = 1;
timeout = agk::Timer() + 5.0f;
break;
case 1:
// check for logging in
agk::Print("Logging In");
if (agk::GetFacebookLoggedIn()||(agk::Timer()>timeout))
{
curr_state = 2;
logged = (agk::GetFacebookLoggedIn()==1?true:false);
}
break;
case 2:
// do app activities
if (logged) agk::Print("Connected to Facebook!");
else agk::Print("Could not log in to Facebook!");
agk::Print("");
agk::Print("Touch anywhere to exit");
break;
}
// sync display
agk::Sync();
}
// Called when the app ends
void app::End ( void )
{
// clean up, if not already done
}
void app::closeThisApp()
{
// indicate done
app::did_end = true;
// completely exit the app
#ifdef AGKWINDOWS
PostQuitMessage(0);
#endif
#ifdef AGKIOS
// forcing a quit in iOS is against recommended guidelines - use HOME button
// the exit button is disabled on AGKIOS builds
// but if you want to do so, this is the code
agk::MasterReset();
exit(0);
#endif
#ifdef IDE_ANDROID
// similar to iOS, an exit button should not be done
// but if you want to do so, this is the code
agk::MasterReset();
exit(0);
#endif
#ifdef IDE_MAC
glfwCloseWindow();
#endif
}
It was also run from Eclipse (it fails just the same as if run directly) and the LogCat produced (this is all of it):
09-02 17:28:41.964: I/threaded_app(9536): Creating: 0x67aa8c20
09-02 17:28:41.964: I/threaded_app(9536): Config: mcc=310 mnc=0 lang=en cnt=US orien=1 touch=3 dens=213 keys=1 nav=1 keysHid=3 navHid=0 sdk=17 size=3 long=1 modetype=1 modenight=1
09-02 17:28:41.964: I/threaded_app(9536): Start: 0x67aa8c20
09-02 17:28:41.964: I/threaded_app(9536): activityState=10
09-02 17:28:41.964: I/threaded_app(9536): Resume: 0x67aa8c20
09-02 17:28:41.984: I/threaded_app(9536): activityState=11
09-02 17:28:41.984: I/native-activity(9536): App Resumed
09-02 17:28:41.994: I/threaded_app(9536): InputQueueCreated: 0x67aa8c20 -- 0x64014008
09-02 17:28:41.994: I/threaded_app(9536): APP_CMD_INPUT_CHANGED
09-02 17:28:41.994: I/threaded_app(9536): Attaching input queue to looper
09-02 17:28:42.024: I/threaded_app(9536): NativeWindowCreated: 0x67aa8c20 -- 0x631f0010
09-02 17:28:42.024: I/threaded_app(9536): APP_CMD_INIT_WINDOW
09-02 17:28:42.024: I/native-activity(9536): Window Init
09-02 17:28:42.024: I/threaded_app(9536): WindowFocusChanged: 0x67aa8c20 -- 1
09-02 17:28:42.034: D/libEGL(9536): loaded /system/lib/egl/libEGL_tegra.so
09-02 17:28:42.064: D/libEGL(9536): loaded /system/lib/egl/libGLESv1_CM_tegra.so
09-02 17:28:42.074: D/libEGL(9536): loaded /system/lib/egl/libGLESv2_tegra.so
09-02 17:28:42.094: W/native-activity(9536): R: 8, G: 8, B: 8, A: 8, D: 16, W: 3175, F: 1, S: 0, R: 5
09-02 17:28:42.094: W/native-activity(9536): R: 8, G: 8, B: 8, A: 8, D: 16, W: 3175, F: 1, S: 0, R: 4
09-02 17:28:42.094: W/native-activity(9536): R: 8, G: 8, B: 8, A: 8, D: 16, W: 3175, F: 1, S: 8, R: 5
09-02 17:28:42.094: W/native-activity(9536): R: 8, G: 8, B: 8, A: 8, D: 16, W: 3175, F: 1, S: 8, R: 4
09-02 17:28:42.094: W/native-activity(9536): R: 8, G: 8, B: 8, A: 8, D: 16, W: 1125, F: 1, S: 0, R: 4
09-02 17:28:42.094: W/native-activity(9536): R: 8, G: 8, B: 8, A: 8, D: 16, W: 1125, F: 1, S: 0, R: 4
09-02 17:28:42.094: W/native-activity(9536): R: 8, G: 8, B: 8, A: 8, D: 16, W: 1125, F: 1, S: 8, R: 4
09-02 17:28:42.094: W/native-activity(9536): R: 8, G: 8, B: 8, A: 8, D: 16, W: 1125, F: 1, S: 8, R: 4
09-02 17:28:42.094: E/native-activity(9536): grouper
09-02 17:28:42.094: E/native-activity(9536): Nexus 7
09-02 17:28:42.104: W/native-activity(9536): Result: 0
09-02 17:28:42.114: W/native-activity(9536): Width: 800 Height: 1205
09-02 17:28:42.114: W/native-activity(9536): Initialising
09-02 17:28:42.114: W/dalvikvm(9536): dvmFindClassByName rejecting 'com/thegamecreators/agk_player/AGKHelper'
09-02 17:28:42.124: I/dalvikvm(9536): Could not find method com.google.android.gcm.GCMRegistrar.checkDevice, referenced from method com.thegamecreators.agk_player.AGKHelper.registerPushNotification
09-02 17:28:42.124: W/dalvikvm(9536): VFY: unable to resolve static method 2047: Lcom/google/android/gcm/GCMRegistrar;.checkDevice (Landroid/content/Context;)V
09-02 17:28:42.124: D/dalvikvm(9536): VFY: replacing opcode 0x71 at 0x000c
09-02 17:28:42.424: I/native-activity(9536): Gained Focus
09-02 17:28:42.564: I/threaded_app(9536): SaveInstanceState: 0x67aa8c20
09-02 17:28:42.574: I/native-activity(9536): Save State
09-02 17:28:42.574: I/threaded_app(9536): APP_CMD_SAVE_STATE
09-02 17:28:42.574: I/threaded_app(9536): Pause: 0x67aa8c20
09-02 17:28:42.604: I/threaded_app(9536): activityState=13
09-02 17:28:42.604: I/native-activity(9536): App Paused
09-02 17:28:42.644: W/dalvikvm(9536): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 17:28:42.644: W/dalvikvm(9536): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 17:28:42.644: W/dalvikvm(9536): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 17:28:42.644: W/dalvikvm(9536): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 17:28:42.644: I/dalvikvm(9536): Could not find method android.support.v4.content.LocalBroadcastManager.getInstance, referenced from method com.facebook.Session.postActiveSessionAction
09-02 17:28:42.644: W/dalvikvm(9536): VFY: unable to resolve static method 270: Landroid/support/v4/content/LocalBroadcastManager;.getInstance (Landroid/content/Context;)Landroid/support/v4/content/LocalBroadcastManager;
09-02 17:28:42.644: D/dalvikvm(9536): VFY: replacing opcode 0x71 at 0x0009
09-02 17:28:42.664: W/dalvikvm(9536): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 17:28:42.664: W/dalvikvm(9536): VFY: unable to find class referenced in signature (Landroid/support/v4/app/Fragment;)
09-02 17:28:42.674: D/AndroidRuntime(9536): Shutting down VM
09-02 17:28:42.674: W/dalvikvm(9536): threadid=1: thread exiting with uncaught exception (group=0x41ede930)
09-02 17:28:42.674: E/AndroidRuntime(9536): FATAL EXCEPTION: main
09-02 17:28:42.674: E/AndroidRuntime(9536): java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
09-02 17:28:42.674: E/AndroidRuntime(9536): at com.facebook.Session.postActiveSessionAction(Session.java:1341)
09-02 17:28:42.674: E/AndroidRuntime(9536): at com.facebook.Session.setActiveSession(Session.java:841)
09-02 17:28:42.674: E/AndroidRuntime(9536): at com.thegamecreators.agk_player.MyFacebookActivity.onCreate(MyFacebookActivity.java:39)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.app.Activity.performCreate(Activity.java:5104)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.os.Handler.dispatchMessage(Handler.java:99)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.os.Looper.loop(Looper.java:137)
09-02 17:28:42.674: E/AndroidRuntime(9536): at android.app.ActivityThread.main(ActivityThread.java:5041)
09-02 17:28:42.674: E/AndroidRuntime(9536): at java.lang.reflect.Method.invokeNative(Native Method)
09-02 17:28:42.674: E/AndroidRuntime(9536): at java.lang.reflect.Method.invoke(Method.java:511)
09-02 17:28:42.674: E/AndroidRuntime(9536): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-02 17:28:42.674: E/AndroidRuntime(9536): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-02 17:28:42.674: E/AndroidRuntime(9536): at dalvik.system.NativeStart.main(Native Method)
It is the same issue for both Tiers. And it happens in the same place (also the same place there is an issue in iOS).
Googling the main error code ("Could not find method android.support.v4.content.LocalBroadcastManager.getInstance") produced some things that seem to indicate the Facebook SDK may be out of sync with the android-support-v4.jar file.
It may be that the Facebook SDK and android-support-v4.jar file in my Android setup are different from those used to build the Player on the TGC site. Since I am using the facebook directory from teh installation, that might mean that the android-support-v4.jar file is the culprit.
My android-support-v4.jar file is dated 30-May-2013 and is 484,258 bytes in size.
So, in combination with the
Facebook login issues with iOS I reported, make using Facebook a bit difficult right now.
I am open to help and suggestions.
I am using only Tier 2 for my own projects.
And it looks like the issue as it plays in the TGC Player and in iOS are related. They both have a problem getting back to the original app. At least that is how I interpret where it is hanging on Android with "Please Wait...".
EDIT: I found the fix for the crash on Android. Open the project properties, click on 'Java Build Path', then on the 'Order and Export' tab and make sure everything is checked (especially the 'android-support-v4.jar' entry.
So, now everything has the same problem. It gets stuck on "Please Wait..." and the login fails.
Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master