Zamama Zaman
Zamama Zaman

Reputation: 1

Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 17.3.99]

I want to send device-to-device notifications in flutter using OneSignal. I have tried all the things google service update Gradle version update, flutter clean, restart, rebuild

In flutter adding dependency of Onesignal following error occurs

Error

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 17.3.99].
     Required by:
         project :app > com.onesignal:OneSignal:3.16.0
      > Failed to list versions for com.google.firebase:firebase-messaging.
         > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/firebase/firebase-messaging/maven-metadata.xml.
            > Could not get resource 'https://google.bintray.com/exoplayer/com/google/firebase/firebase-messaging/maven-metadata.xml'.
               > Could not GET 'https://google.bintray.com/exoplayer/com/google/firebase/firebase-messaging/maven-metadata.xml'. Received status code 403 from server: Forbidden
   > Could not resolve com.google.android.gms:play-services-base:[10.2.1, 16.1.99].
     Required by:
         project :app > com.onesignal:OneSignal:3.16.0
      > Failed to list versions for com.google.android.gms:play-services-base.
         > Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-base/maven-metadata.xml.
            > Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-base/maven-metadata.xml'.
               > Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-base/maven-metadata.xml'. Received status code 403 from server: Forbidden

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 46s
Exception: Gradle task assembleDebug failed with exit code 1

project build gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        mavenLocal()
        gradlePluginPortal()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath 'com.google.gms:google-services:4.3.8'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

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

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

App build gradle

 buildscript {
     repositories {
         // ...
         maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
     }
     dependencies {
         // ...
         // OneSignal-Gradle-Plugin
         classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'

     }
 }

 apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
    compileSdkVersion 28

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    lintOptions {
        disable 'InvalidPackage'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.ml_kit_in_flutter"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.multidex:multidex:2.0.1'
}


googleServices.disableVersionCheck = true

Here is all the dependency of pubspec.yaml

version: 1.0.0+1

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_tts: ^0.6.0
  camera: ^0.5.8+11
  cupertino_icons: ^0.1.3
  speech_to_text: ^2.4.1
  clipboard: ^0.1.2+8
  table_calendar: ^2.2.3
  tflite: ^1.1.1
  path_provider: ^1.6.11
  tflite_flutter: ^0.5.0
  image: ^2.1.12
  provider: ^3.1.0
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  onesignal_flutter: ^2.6.3
  http: ^0.12.2
  firebase_core: "^0.7.0"
  firebase_auth: "^0.20.1"
  cloud_firestore: "^0.16.0+1"
  firebase_storage: "^7.0.0"

  dio: ^3.0.0
  flutter_polyline_points: ^0.0.1
  google_maps_flutter: ^0.5.21+15
  geolocator: ^5.3.2
  intl: ^0.16.1
  path: ^1.7.0
  uuid: ^2.1.0
  image_picker: ^0.6.7+22
  firebase_ml_vision: ^0.9.8
  awesome_notifications: ^0.0.5

dev_dependencies:
  flutter_test:
    sdk: flutter

Upvotes: 0

Views: 1963

Answers (2)

Thiran Hettiarachchi
Thiran Hettiarachchi

Reputation: 359

I tried several solutions and went back to One Signal documentation to get rid of this issue.

Add the following lines to your android/app/build.gradle

    buildscript {
      repositories {
         // ...
         maven { url 'https://plugins.gradle.org/m2/' } // Gradle Plugin Portal
      }
      dependencies {
        // ...
        // OneSignal-Gradle-Plugin
       classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
      }
    }

   apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

Upvotes: 0

mohamed yahia
mohamed yahia

Reputation: 111

if you do upgrade to Gradle 6.0 this will fix the build issue . To upgrade Gradle update the version number in your project's gradle\wrapper\gradle-wrapper.properties file.

distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-all.zip

as mentioned here https://github.com/OneSignal/OneSignal-Gradle-Plugin/issues/94#issuecomment-626399384

Upvotes: 1

Related Questions