0

I would like to build my app client side compatible with both Facebook Android SDK 3.x and 4.x since Facebook Android SDK deprecated "Session" class.

How can I write the build.gradle to create one aar file for v3.x and one for v4.x.

Thanks.

1 Answer 1

0

You can use flavors.

Just define your flavors in the build.gradle

android {
    ....    

    productFlavors {
        flavorSdk3 {
            ...
        }


        flavorSdk4 {
            ...
        }
    }
}

Then you can use different dependencies for your flavors:

dependencies {
    flavorSdk3Compile "..."
    flavorSdk4Compile "..."
}
2
  • What should I put in the flavor? Can I do this flavorSdk3 { dependencies { compile 'com.facebook.android:facebook-android-sdk:3.20.0' } } Nov 18, 2015 at 22:00
  • Inside the flavor you can define values specified for each flavor for example the applicationId, a buildConfigField, a custom sourceset or a custom keystore signing. The dependencies block should be outside the android block. Nov 19, 2015 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.