Facebook crashes app on Android

Hello Corona SDK community,

I implemented Facebook into my app the other day, using the GGFacebook library, and everything is working well on iOS. However, when I try to use the Facebook feature on Android, I get, “Unfortunately, (Your App) has stopped working”.

I set up the key hash and Facebook developer app correctly, or so I believe, so I’m not sure what’s up.

Hopefully someone has had this problem and found the solution.

Thanks,

David

Oh also there are no error or warning messages in the console.

Hi @davidgmonical.  When you say “in the console” are  you talking about using “adb logcat”?  or your Corona build window?  If you’re using “adb logcat” are you filtering only Corona messages?

If you’re doing this: 

adb logcat Corona:v \*:s

do this instead: 

adb logcat 

and see if there are any more messages.

Alright so I found this:

E/AndroidRuntime(14590): FATAL EXCEPTION: main

E/AndroidRuntime(14590): com.facebook.FacebookException: Attempted to use a Session that was not open.

E/AndroidRuntime(14590):     at com.facebook.widget.WebDialog$BuilderBase.<init>(WebDialog.java:394)

E/AndroidRuntime(14590):     at com.facebook.widget.WebDialog$FeedDialogBuilder.<init>(WebDialog.java:555)

E/AndroidRuntime(14590):     at com.ansca.corona.facebook.FacebookController$2.run(FacebookController.java:286)

E/AndroidRuntime(14590):     at android.os.Handler.handleCallback(Handler.java:730)

E/AndroidRuntime(14590):     at android.os.Handler.dispatchMessage(Handler.java:92)

E/AndroidRuntime(14590):     at android.os.Looper.loop(Looper.java:137)

E/AndroidRuntime(14590):     at android.app.ActivityThread.main(ActivityThread.java:5455)

E/AndroidRuntime(14590):     at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime(14590):     at java.lang.reflect.Method.invoke(Method.java:525)

E/AndroidRuntime(14590):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)

E/AndroidRuntime(14590):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

E/AndroidRuntime(14590):     at dalvik.system.NativeStart.main(Native Method)

I/ActivityManager(  394): Notify an ApplicationCrash

Still not sure What the issue is, but clearly it’s there.

Let me know if you have any ideas.

Thanks

Are there more messages before it?  Any warnings?

Sorry for this long log but I don’t really know what to look for. This is what comes before the FATAL EXCEPTION line:

E/MP-Decision( 1312): Error setting a sleep mode for secondary cores - -38

W/ActivityManager(  394): mDVFSHelper.acquire()

D/SensorService(  394):  [AR] -1.1 5.3 8.7

D/SensorService(  394): AutoRotationSensor::process: Ar_SensorChanged oldrotation = [0], rotation = [255]

V/WindowOrientationListener(  394): Rotation Sensor : x=255.0

I/Corona  (14891): name    Flappy Cape - Super Balloony

I/Corona  (14891): link    https://itunes.apple.com/us/app/flappycape:superballoony/id821649610?mt=8&ign-mpt=uo%3D4

I/Corona  (14891): caption    Download Now!

I/Corona  (14891): description    I just got a score of 0 in Flappy Cape - Super Balloony! Bet you can’t beat that!

I/Corona  (14891): picture    https://lh3.ggpht.com/FWQ6wgTZOcc1CV4JH5d8oTmqqDPsr0XLOC5nByYSjVkXoyhLaX2Zm0pyYCAGOG4RXmI=h310-rw

D/SensorManager(14891): unregisterListener ::  

D/SensorService(  394): SensorDevice::activating sensor handle=4 ns=10000000 

V/Sensors (  394): setDelay - sensor Accelerometer (handle 4), rate 10 ms (100.00 Hz)

V/WindowManager(  394): rotationForOrientationLw(orient=-1, last=0); user=0  sensorRotation=-1 isCoverOpen=true mLidState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false

E/Sensors (  394): activatePendingSensors : mEnabled = 10

E/Sensors (  394): requested_sensors(70) from kernel

V/WindowManager(  394): Application requested orientation -1, got rotation 0 which has compatible metrics

D/WindowManager(  394): computeScreenConfigurationLocked() set config.orientation=1 dw=720 dh=1280 Callers=com.android.server.wm.WindowManagerService.updateOrientationFromAppTokensLocked:5171 com.android.server.wm.WindowManagerService.updateOrientationFromAppTokens:5142 com.android.server.am.ActivityStack.realStartActivityLocked:1018 

D/PowerManagerService(  394): setKeyboardVisibility: false

D/SensorService(  394):  [AR] -0.9 5.8 7.9

D/SensorService(  394): AutoRotationSensor::process: Ar_SensorChanged oldrotation = [255], rotation = [0]

V/WindowOrientationListener(  394): Rotation Sensor : x=0.0

E/MP-Decision( 1312): mpdecision_server: received msg --Nw 1.99 --Tw 140 --Ns 1.1 --Ts 190 --util_h 70 --util_l 60

E/MP-Decision( 1312): mpdecision_server(): New Decision parameters Nw=1.990000, Tw=140, Ns=1.100000, Ts=190, util_h=70, util_l=60

E/MP-Decision( 1312): mpdecision_server()-def apply: New Decision parameters Nw=1.900000, Tw=140, Ns=1.100000, Ts=190, util_h=75, util_l=20

E/MP-Decision( 1312): mpdecision_server()-def apply: New Decision parameters Nw=2.700000, Tw=90, Ns=2.100000, Ts=240, util_h=400, util_l=0

E/MP-Decision( 1312): mpdecision_server()-def apply: New Decision parameters Nw=3.500000, Tw=90, Ns=3.100000, Ts=240, util_h=400, util_l=0

D/AndroidRuntime(14891): Shutting down VM

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

Thanks for your help!

Can you post your code where you are initialziing facebook and logging in?

Well I’m using GGFacebook so this is it:

*the x’s is the facebook app id, the listener doesn’t get called, and for permissions I use “publish-stream” which is the default

local facebook = GGFacebook:new("xxxxxxxxxxxxxxxxxxx", listener, permissions ) facebook:login() local link = "https://itunes.apple.com/us/app/flappycape:superballoony/id821649610?mt=8&ign-mpt=uo%3D4" local imageLink = "https://lh3.ggpht.com/FWQ6wgTZOcc1CV4JH5d8oTmqqDPsr0XLOC5nByYSjVkXoyhLaX2Zm0pyYCAGOG4RXmI=h310-rw" local name = "Flappy Cape - Super Balloony" local caption = "Download Now!" local description = "I just got a score of "..self[4].text.." in Flappy Cape - Super Balloony! Bet you can't beat that!" facebook:makePost(link, imageLink, name, caption, description)

You will need to ask Graham/GlitchGames then since you are using GGFacebook

Oh also there are no error or warning messages in the console.

Hi @davidgmonical.  When you say “in the console” are  you talking about using “adb logcat”?  or your Corona build window?  If you’re using “adb logcat” are you filtering only Corona messages?

If you’re doing this: 

adb logcat Corona:v \*:s

do this instead: 

adb logcat 

and see if there are any more messages.

Alright so I found this:

E/AndroidRuntime(14590): FATAL EXCEPTION: main

E/AndroidRuntime(14590): com.facebook.FacebookException: Attempted to use a Session that was not open.

E/AndroidRuntime(14590):     at com.facebook.widget.WebDialog$BuilderBase.<init>(WebDialog.java:394)

E/AndroidRuntime(14590):     at com.facebook.widget.WebDialog$FeedDialogBuilder.<init>(WebDialog.java:555)

E/AndroidRuntime(14590):     at com.ansca.corona.facebook.FacebookController$2.run(FacebookController.java:286)

E/AndroidRuntime(14590):     at android.os.Handler.handleCallback(Handler.java:730)

E/AndroidRuntime(14590):     at android.os.Handler.dispatchMessage(Handler.java:92)

E/AndroidRuntime(14590):     at android.os.Looper.loop(Looper.java:137)

E/AndroidRuntime(14590):     at android.app.ActivityThread.main(ActivityThread.java:5455)

E/AndroidRuntime(14590):     at java.lang.reflect.Method.invokeNative(Native Method)

E/AndroidRuntime(14590):     at java.lang.reflect.Method.invoke(Method.java:525)

E/AndroidRuntime(14590):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)

E/AndroidRuntime(14590):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

E/AndroidRuntime(14590):     at dalvik.system.NativeStart.main(Native Method)

I/ActivityManager(  394): Notify an ApplicationCrash

Still not sure What the issue is, but clearly it’s there.

Let me know if you have any ideas.

Thanks

Are there more messages before it?  Any warnings?

Sorry for this long log but I don’t really know what to look for. This is what comes before the FATAL EXCEPTION line:

E/MP-Decision( 1312): Error setting a sleep mode for secondary cores - -38

W/ActivityManager(  394): mDVFSHelper.acquire()

D/SensorService(  394):  [AR] -1.1 5.3 8.7

D/SensorService(  394): AutoRotationSensor::process: Ar_SensorChanged oldrotation = [0], rotation = [255]

V/WindowOrientationListener(  394): Rotation Sensor : x=255.0

I/Corona  (14891): name    Flappy Cape - Super Balloony

I/Corona  (14891): link    https://itunes.apple.com/us/app/flappycape:superballoony/id821649610?mt=8&ign-mpt=uo%3D4

I/Corona  (14891): caption    Download Now!

I/Corona  (14891): description    I just got a score of 0 in Flappy Cape - Super Balloony! Bet you can’t beat that!

I/Corona  (14891): picture    https://lh3.ggpht.com/FWQ6wgTZOcc1CV4JH5d8oTmqqDPsr0XLOC5nByYSjVkXoyhLaX2Zm0pyYCAGOG4RXmI=h310-rw

D/SensorManager(14891): unregisterListener ::  

D/SensorService(  394): SensorDevice::activating sensor handle=4 ns=10000000 

V/Sensors (  394): setDelay - sensor Accelerometer (handle 4), rate 10 ms (100.00 Hz)

V/WindowManager(  394): rotationForOrientationLw(orient=-1, last=0); user=0  sensorRotation=-1 isCoverOpen=true mLidState=-1 mDockMode=0 mHdmiPlugged=false mAccelerometerDefault=false

E/Sensors (  394): activatePendingSensors : mEnabled = 10

E/Sensors (  394): requested_sensors(70) from kernel

V/WindowManager(  394): Application requested orientation -1, got rotation 0 which has compatible metrics

D/WindowManager(  394): computeScreenConfigurationLocked() set config.orientation=1 dw=720 dh=1280 Callers=com.android.server.wm.WindowManagerService.updateOrientationFromAppTokensLocked:5171 com.android.server.wm.WindowManagerService.updateOrientationFromAppTokens:5142 com.android.server.am.ActivityStack.realStartActivityLocked:1018 

D/PowerManagerService(  394): setKeyboardVisibility: false

D/SensorService(  394):  [AR] -0.9 5.8 7.9

D/SensorService(  394): AutoRotationSensor::process: Ar_SensorChanged oldrotation = [255], rotation = [0]

V/WindowOrientationListener(  394): Rotation Sensor : x=0.0

E/MP-Decision( 1312): mpdecision_server: received msg --Nw 1.99 --Tw 140 --Ns 1.1 --Ts 190 --util_h 70 --util_l 60

E/MP-Decision( 1312): mpdecision_server(): New Decision parameters Nw=1.990000, Tw=140, Ns=1.100000, Ts=190, util_h=70, util_l=60

E/MP-Decision( 1312): mpdecision_server()-def apply: New Decision parameters Nw=1.900000, Tw=140, Ns=1.100000, Ts=190, util_h=75, util_l=20

E/MP-Decision( 1312): mpdecision_server()-def apply: New Decision parameters Nw=2.700000, Tw=90, Ns=2.100000, Ts=240, util_h=400, util_l=0

E/MP-Decision( 1312): mpdecision_server()-def apply: New Decision parameters Nw=3.500000, Tw=90, Ns=3.100000, Ts=240, util_h=400, util_l=0

D/AndroidRuntime(14891): Shutting down VM

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

Thanks for your help!

Can you post your code where you are initialziing facebook and logging in?

Well I’m using GGFacebook so this is it:

*the x’s is the facebook app id, the listener doesn’t get called, and for permissions I use “publish-stream” which is the default

local facebook = GGFacebook:new("xxxxxxxxxxxxxxxxxxx", listener, permissions ) facebook:login() local link = "https://itunes.apple.com/us/app/flappycape:superballoony/id821649610?mt=8&ign-mpt=uo%3D4" local imageLink = "https://lh3.ggpht.com/FWQ6wgTZOcc1CV4JH5d8oTmqqDPsr0XLOC5nByYSjVkXoyhLaX2Zm0pyYCAGOG4RXmI=h310-rw" local name = "Flappy Cape - Super Balloony" local caption = "Download Now!" local description = "I just got a score of "..self[4].text.." in Flappy Cape - Super Balloony! Bet you can't beat that!" facebook:makePost(link, imageLink, name, caption, description)

You will need to ask Graham/GlitchGames then since you are using GGFacebook