问题
In my app\build.gradle file, I have compile 'com.facebook.android:facebook-android-sdk:3.23.1'
. In my BaseActivity.java file (where I have "public class BaseActivity extends Activity"), I am trying to use this: import com.facebook.FacebookSdk;
. This is the error I get:
Error:(8, 20) error: cannot find symbol class FacebookSdk
Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > Compilation failed; see the compiler error output for details.
I am using https://developers.facebook.com/quickstarts/ to follow the instructions for adding Facebook SDK to a project. One of the steps is: "Import Facebook SDK into your app", and they provide the following line:
import com.facebook.FacebookSdk;
Is it possible to do this with Facebook SDK 3.23.1? I wonder if the instructions imply the use of Facebook SDK 4.0.0 or higher.
UPDATE: I am copying my dependencies below.
dependencies {
compile 'com.google.code.gson:gson:2.2.4'
compile files('libs/AndroidSDK-2.15.9.jar')
compile files('libs/core.jar')
compile files('libs/easyfacebookandroidsdk_2.3.jar')
compile files('libs/PayPal_MPL.jar')
compile files('libs/signpost-commonshttp4-1.2.1.1.jar')
compile files('libs/signpost-core-1.2.1.1.jar')
compile files('libs/socialauth-4.2.jar')
compile files('libs/twitter4j-core-3.0.5.jar')
compile files('libs/urbanairship-lib-3.3.0.jar')
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.facebook.android:facebook-android-sdk:3.23.1'}
回答1:
No, “import com.facebook.FacebookSdk;” is only available from Facebook SDK 4.0.0. Yes, it is possible to use Facebook Analytics with Facebook SDK v3.x. I finally have Facebook Analytics working using Facebook SDK v3.23.1. I used the AppEventsLogger class as explained at https://developers.facebook.com/docs/reference/android/3.23.1/class/AppEventsLogger/.
回答2:
Use the latest version of facebook SDK. I've integrated it recently and it's working fine.
dependencies{
compile 'com.facebook.android:facebook-android-sdk:4.+'
}
来源:https://stackoverflow.com/questions/42493510/can-i-use-import-com-facebook-facebooksdk-with-facebook-sdk-3-23-1