Search code examples
androidfacebookkotlinads

Facebook Ads SDK integration changing existing project configuration


I have written an app using Kotlin which has all integration which uses Fragment/Activity. Now I'm integrating Facebook Ads SDK, but as soon dependency get sync, application code started to throw compilation error on building.

implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

Most of these are relate with how kotlin null assertion I have used across application. PFA. enter image description here

enter image description here

Any chance FB SDK changed default property but how come that is possible though this has added as external SDK.

Any suggestion what is issue & how can this be fixed ?


Solution

  • Got fix for this. This was issue with dependent lib version mis matching, it was different in my app project & FB SDK. There is well directed solution propose here

    And I modified it as per my need, In following case both app & added 3rd part libs will use same version 26.1.0.

    // Configuration need to align & force FB SDK to use app using version which is 26.1.0.
    configurations.all {
        resolutionStrategy.eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == 'com.android.support') {
                details.useVersion "26.1.0"
            }
        }
    }