Search code examples
androidflutterruntime-errorfacebook-authenticationandroidx-lifecycle

Error when adding Facebook Authentication to flutter App


I'm going crazy because I'm trying to solve this from 3 days ago :) any one can please help me. Note: the app is already on google play, now I'm working on version 2 of app.

I'm trying to add Facebook Authentication to an existing flutter app, i was add the package to pubspec.yaml file, and doing all configuration from official docs. now when trying to debug its show error :

Execution failed for task ':flutter_facebook_auth:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':flutter_facebook_auth:debugCompileClasspath'.
   > Could not find lifecycle-common-2.3.0.jar (androidx.lifecycle:lifecycle-common:2.3.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/lifecycle/lifecycle-common/2.3.0/lifecycle-common-2.3.0.jar

Here is some details about project:

Flutter pubspec.yaml file :

name: red_gold
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.4+3

environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  get: ^4.3.8
  flutter_secure_storage: ^5.0.2
  shared_preferences: ^2.0.7
  http: ^0.13.3
  dio: ^4.0.0
  image_cropper: ^1.4.1
  image_picker: ^0.8.4+2
  flutter_easyloading: ^3.0.3
  retry: ^3.1.0
  cached_network_image: ^3.1.0
  flutter_switch: ^0.3.2
  get_storage: ^2.0.3
  flutter_html: ^2.1.4
  flutter_facebook_auth: ^4.1.1




dev_dependencies:
  flutter_lints: ^1.0.4
  flutter_test:
    sdk: flutter
  flutter_launcher_icons: "^0.9.2"

flutter_icons:
  android: true
  ios: true
  image_path: "assets/images/Logo.png"



# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
   - assets/images/

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware.

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
   - family: ACaslon Bold
     fonts:
       - asset: assets/fonts/ACaslonPro-Bold.otf
       - asset: assets/fonts/ACaslonPro-BoldItalic.otf
         style: italic
   - family: Acaslon SemiBold
     fonts:
       - asset: assets/fonts/ACaslonPro-SemiBold.otf
       - asset: assets/fonts/ACaslonPro-SemiBoldItalic.otf
         style: italic
   - family: Acaslon Regular
     fonts:
       - asset: assets/fonts/ACaslonPro-Regular.otf

  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

this is from my app/build.gradle file :

 minSdkVersion 19
        targetSdkVersion 30

and this from android/build/gradle:

buildscript {
    repositories {
        google()
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
        classpath 'com.android.support:multidex:1.0.3'


    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Solution

  • Try adding maven { url 'https://maven.google.com' } to your build script repositories:

     repositories {
            jcenter()
            maven { url 'https://maven.google.com' }
            google()
        }