Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding What the Android Facebook SDK Version Is

Tags:

How do I find out the version of the current SDK is installed or referenced by my application? I have looked through the class files and the manifest but there is no reference as to what version it is.

Thanks in advance.

like image 905
StuStirling Avatar asked Oct 07 '13 13:10

StuStirling


People also ask

What sdk version do I have Android?

Navigate to “Appearance & Behavior” > “System Settings” > “Android SDK” and now you can see the SDK versions that were installed in the “API Level” and “Name” columns (focus on “API Level”).

What is Facebook SDK Android?

The Facebook SDK for Android gives you access to the following features: Facebook Login — A secure and convenient way for people to log into your app or website by using their Facebook credentials. Sharing — Enable people to post to Facebook from your app. People can share, send a message, and share to stories.


1 Answers

You have FacebookSdkVersion class with the current version: https://github.com/facebook/facebook-android-sdk/blob/master/facebook/src/com/facebook/FacebookSdkVersion.java

final class FacebookSdkVersion {     public static final String BUILD = "3.5.2";     public static final String MIGRATION_BUNDLE = "fbsdk:20130708"; } 

Since this class is without modifier and you can't access it from your package, use a reflection. This will return you the sdk version:

private String getFacebookSDKVersion() {     String sdkVersion = null;     ClassLoader classLoader = getClass().getClassLoader();     Class<?> cls;     try     {         cls = classLoader.loadClass("com.facebook.FacebookSdkVersion");         Field field = cls.getField("BUILD");         sdkVersion = String.valueOf(field.get(null));     }     catch (ClassNotFoundException e)     {         // error     }     catch (NoSuchFieldException e)     {         // error     }     catch (IllegalArgumentException e)     {         // error     }     catch (IllegalAccessException e)     {         // error     }     return sdkVersion; } 
like image 139
sromku Avatar answered Oct 15 '22 02:10

sromku