简体   繁体   中英

How to enable logging in facebook SDK 3.0?

recently i am trying to get my hash key for my android app that uses facebook.

The problem is the method through the command prompt is not working for me.

So i found a new solution that says you can use the facebook message to produce an error message that will give you the hash key itself.

They say you are supposed to set private boolean ENABLE_LOGGING = false; to true in the facebook util.java class. The problem is i dont see in the class where enable logging is supposed to go.

Could anyone tell me how to get the sdk to print out logging in the logcat?

To enable logging call the function Settings.addLoggingBehavior(LoggingBehavior behavior)

For example if you want to display Request information call

Settings.addLoggingBehavior(LoggingBehavior.REQUESTS);

You can check the class LoggingBehavior to debug other operations: https://developers.facebook.com/docs/reference/android/3.0/LoggingBehavior

According Pascal's comment on a similar thread, this method is not working since december 2012. So you will have to use the commandprompt method to get the correct hash key.

"ENABLE_LOG cannet be changed anymore since December 2012 – Pascal Klein Feb 24 at 3:41" here is a link to the thread: Android: Facebook login doesn't work

I tried several commands in the command prompt and now I finally found one that worked for me. I hope it will work for you too. (I use x64 Windows 7)

Download this version of openssl: openssl for x64 Windows

Make a folder called openssl in your C:\\ directory.

Extract the openssl zip in the openssl folder.

Go to the location of the keytool.exe (C:\\Program Files (x86)\\Java...\\bin)

While holding shift, right click the bin folder and open a command prompt window.

Enter the following:

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\"username"\.android\debug.keystore" | "C:\openssl\bin\openssl" sha1 -binary | "C:\openssl\bin\openssl" base64 

( replace "username" with your username . Without the quotes of course)

You must enter the password: android

Your hash key should appear. (if you get a '=' in the key, don't delete it. Its part of the key)

Good luck building your application!

credits to C Abernathy for posting this method.

Normally Android libraries can use BuildConfig.DEBUG to determine if the app is in debug mode. However, due to a bug in Gradle, Android libraries are always built with DEBUG set to false. As a workaround, there is a FacebookSdk.setIsDebugEnabled(boolean) method so you can directly set the debug mode from your app. This enables debug logging from the SDK.

You can also set logging behaviors with FacebookSdk.addLoggingBehavior(LogginBehavior) to enable logging for different categories of messages. See the Android SDK Reference, LoggingBehavior .

From here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM