简体   繁体   English

用于SDK v3.23.1的Facebook SDK初始化以实现Android的应用程序事件

[英]Facebook SDK Initialization for SDK v3.23.1 to implement App Events for Android

I am trying to follow the instructions at https://developers.facebook.com/docs/app-events/android#legacy-activation in the section "Legacy SDK Initialization". 我正在尝试按照“旧版SDK初始化”部分中https://developers.facebook.com/docs/app-events/android#legacy-activation中的说明进行操作。 They say that "in the Facebook SDK for Android v4.18, and earlier, the SDK must be initialized". 他们说“在适用于Android v4.18和更早版本的Facebook SDK中,必须初始化SDK”。 I am using Facebook SDK v3.23.1. 我正在使用Facebook SDK v3.23.1。 They provide a code to demonstrate how to initialize the SDK. 他们提供了代码来演示如何初始化SDK。 The problem that I am experiencing is that as part of the sample code, they use the following two lines: 我遇到的问题是,作为示例代码的一部分,它们使用以下两行:

import com.facebook.FacebookSdk;
FacebookSdk.sdkInitialize(getApplicationContext());

When I try to do that, I get the following error: 当我尝试这样做时,出现以下错误:

Cannot resolve symbol 'FacebookSdk'

By testing, I realized that import com.facebook.FacebookSdk can only be used from Facebook SDK 4.0.0 and higher, but I am using Facebook SDK 3.23.1. 通过测试,我意识到只能从Facebook SDK 4.0.0和更高版本中使用import com.facebook.FacebookSdk ,但是我正在使用Facebook SDK 3.23.1。 Is there an alternative way to initialize Facebook SDK for SDK v3.23.1? 是否有另一种方法可以初始化用于SDK v3.23.1的Facebook SDK?

The solution was using the AppEventsLogger class by following the instructions at https://developers.facebook.com/docs/reference/android/3.23.1/class/AppEventsLogger/ . 该解决方案按照https://developers.facebook.com/docs/reference/android/3.23.1/class/AppEventsLogger/上的说明使用AppEventsLogger类。 I did not have to initialize Facebook SDK v3.23.1, and I guess it is not even possible to initialize it because they do not provide a method to do that in the SDK 3.23.1 release. 我不必初始化Facebook SDK v3.23.1,我想甚至无法初始化它,因为他们没有在SDK 3.23.1版本中提供实现此目的的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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