LoginButton with native Fragment

后端 未结 5 1526
太阳男子
太阳男子 2021-01-17 20:10

I\'m trying to implement the Facebook LoginButton using the tutorial here https://developers.facebook.com/docs/android/login-with-facebook/v2.0#step2

The problem is

5条回答
  •  深忆病人
    2021-01-17 20:12

    The reason is obvious. Facebook SDK is using the Fragment class from the support library for making it backward compatible and work with older versions of android (API Level < 11). And you must use the same class in your application as well.

    Include the support library android-support-v4.jar in to the libs folder and use the Fragment class from it (for Ant based projects). If you are using Gradle build system, Follow the instruction given in Lei's answer above.

    Update: If your application have high dependency with native library, then you are left with a single option. The Facebook SDK code is available here. Fork it and change the SDK to use native library (Remove the support library from the SDK itself). But keep in mind that, your application will be limited to run on API level greater than 10 (minSdkVersion should be 11).

提交回复
热议问题