Error : Cannot find Facebook SDK Version

683 views Asked by At

the SDK 7.x is not working on Unity 5.1.0f3 , i always got the error version not found . does someone have see this error ?

2

There are 2 answers

0
d12frosted On

Actually, it's just a warning. But you can fix it.

There are several places where facebook plugin calls

FBBuildVersionAttribute.GetVersionAttributeOfType(typeof(AbstractFacebook));

So first, you need to modify FBBuildVersionAttribute to this:

// we are going to apply this attribute to Class
// instead of Assembly
// also make it inheritable for all implementations
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
public class FBBuildVersionAttribute : Attribute
{
    private DateTime buildDate;
    private string buildHash;
    private string buildVersion;

    private string sdkVersion;

    public DateTime Date { get { return buildDate; } }
    public string Hash { get { return buildHash; } }
    public string SdkVersion { get { return sdkVersion; } }
    public string BuildVersion { get { return buildVersion; } }

    public FBBuildVersionAttribute(string sdkVersion, string buildVersion)
    {
        this.buildVersion = buildVersion;
        var parts = buildVersion.Split('.');
        buildDate = DateTime.ParseExact(parts[0], "yyMMdd", System.Globalization.CultureInfo.InvariantCulture);
        buildHash = parts[1];

        this.sdkVersion = sdkVersion;
    }

    public override string ToString()
    {
        return buildVersion;
    }

    public static FBBuildVersionAttribute GetVersionAttributeOfType(Type type)
    {
        foreach (FBBuildVersionAttribute attribute in getAttributes(type))
        {
            return attribute;
        }
        return null;
    }

    private static FBBuildVersionAttribute[] getAttributes(Type type)
    {
        if (type == null)
            throw new ArgumentNullException("type");

        // we want to get attributes from type instead of assmebly
        return (FBBuildVersionAttribute[])(type.GetCustomAttributes(typeof(FBBuildVersionAttribute), false));
    }
}

No you just need to add this attribute to AbstractFacebook:

[FBBuildVersionAttribute("7.0.1", "150604.98558e55096475c")]
public abstract class AbstractFacebook : MonoBehaviour
{
    // ...
}

Note that 98558e55096475c part is trash string. It's not actual build hash, cause I don't have one.

0
Antony Blackett On

Get the latest version of the FB Unity SDK. Change log says it's fixed now.

https://developers.facebook.com/docs/unity/change-log