facebookarchive / react-native-fbsdk

A React Native wrapper around the Facebook SDKs for Android and iOS. Provides access to Facebook login, sharing, graph requests, app events etc.
https://developers.facebook.com/docs/react-native
Other
2.99k stars 906 forks source link

lint gives version specification conflict, even when overridden #489

Open mikebridge opened 5 years ago

mikebridge commented 5 years ago

I am compiling with ./gradlew build, with gradle 4.10.3 on Windows and Mac and I'm getting the following error:

> Task :react-native-fbsdk:lint FAILED
Ran lint on variant release: 19 issues found
Ran lint on variant debug: 19 issues found
Wrote HTML report to file:///C:/Foo/Bar/src/ReactNative/node_modules/react-native-fbsdk/android/build/reports/lint-results.html
Wrote XML report to file:///C:/Foo/Bar/src/ReactNative/node_modules/react-native-fbsdk/android/build/reports/lint-results.xml

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-fbsdk:lint'.
> Lint found errors in the project; aborting build.

  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...

  Errors found:

  C:\Foo\Bar\src\ReactNative\node_modules\react-native-fbsdk\android\build.gradle: Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.0.2. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:cardview-v7:27.0.2 [GradleCompatible]

I thought this could be worked around by overriding with the compatibility libraries for 28.0.0, but this doesn't seem to work:

buildscript {
    ext {
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
   // ...
}
implementation('com.facebook.android:facebook-android-sdk:4.40.0') {
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'appcompat-v7'
    exclude group: 'com.android.support', module: 'cardview-v7'
    exclude group: 'com.android.support', module: 'customtabs'
    exclude group: 'com.android.support', module: 'support-annotations'
    exclude group: 'com.android.support', module: 'support-core-utils'
    exclude group: 'com.android.support', module: ':animated-vector-drawable'
}
implementation project(':react-native-fbsdk')
implementation "com.android.support:appcompat-v7:${supportLibVersion}"
implementation "com.android.support:animated-vector-drawable:${supportLibVersion}"
implementation "com.android.support:exifinterface:${supportLibVersion}"
implementation "com.android.support:cardview-v7:${supportLibVersion}"
implementation "com.android.support:customtabs:${supportLibVersion}"
implementation "com.android.support:support-media-compat:${supportLibVersion}"
implementation "com.android.support:support-v4:${supportLibVersion}"

I tried the suggested method to disable the warning but it continues to appear even with the following:

android {
    lintOptions {
        abortOnError false
    }
}

Environment

React Native Environment Info: System: OS: Windows 10 CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz Memory: 3.01 GB / 15.93 GB Binaries: Yarn: 1.13.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD IDEs: Android Studio: Version 3.2.0.0 AI-181.5540.7.32.5056338

mikebridge commented 5 years ago

This looks like everything is using 28.0.0

./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath

+--- com.facebook.android:facebook-android-sdk:4.40.0
|    +--- com.facebook.android:facebook-core:4.40.0
|    |    +--- com.parse.bolts:bolts-android:1.4.0
|    |    |    +--- com.parse.bolts:bolts-tasks:1.4.0
|    |    |    \--- com.parse.bolts:bolts-applinks:1.4.0
|    |    |         \--- com.parse.bolts:bolts-tasks:1.4.0
|    |    +--- com.android.support:support-annotations:27.0.2 -> 28.0.0
|    |    \--- com.android.support:support-core-utils:27.0.2 -> 28.0.0 (*)
|    +--- com.facebook.android:facebook-common:4.40.0
|    |    +--- com.facebook.android:facebook-core:4.40.0 (*)
|    |    +--- com.android.support:support-v4:27.0.2 -> 28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:support-media-compat:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:versionedparcelable:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-ui:28.0.0 (*)
|    |    |    \--- com.android.support:support-fragment:28.0.0 (*)
|    |    +--- com.android.support:appcompat-v7:27.0.2 -> 28.0.0 (*)
|    |    +--- com.android.support:cardview-v7:27.0.2 -> 28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:customtabs:27.0.2 -> 28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:interpolator:28.0.0 (*)
|    |    |    +--- com.android.support:collections:28.0.0 (*)
|    |    |    \--- com.android.support:support-core-ui:28.0.0 (*)
|    |    \--- com.google.zxing:core:3.3.0
mikebridge commented 5 years ago

Adding this to app/build.gradle seems to disable the check. I don't know if there's a better way to address this:

allprojects {
    // ...
    afterEvaluate {
        if (getPlugins().hasPlugin('android') ||
            getPlugins().hasPlugin('android-library')) {

            println name // for debugging

            configure(android.lintOptions) {
                abortOnError false
            }
        }
    }
}
diego-pascual commented 5 years ago

This wouldn't have to be the solution, but it works for me:

dependencies {
    implementation "com.android.support:appcompat-v7:${SUPPORT_LIB_VERSION}"
    //this lines
    implementation "com.android.support:cardview-v7:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:customtabs:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:support-media-compat:${SUPPORT_LIB_VERSION}"
    implementation "com.android.support:support-v4:${SUPPORT_LIB_VERSION}"
   //
    api 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
    api "com.facebook.android:facebook-android-sdk:${FACEBOOK_SDK_VERSION}"
}

Make sure you have this defined in your build.gradle:

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 19
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
bb-cuongnv commented 5 years ago

same +1