Onesignal-flutter-sdk: Flutter fails to build for Android when firebase in project

Created on 12 Nov 2019  路  12Comments  路  Source: OneSignal/OneSignal-Flutter-SDK

Description:

My pubspec.yaml has the following 3 dependecies:

firebase_analytics: ^5.0.6
firebase_crashlytics: ^0.1.1+2
onesignal_flutter: ^2.2.0

android.build.gradle

repositories {
    google()
    jcenter()
    maven { url 'https://plugins.gradle.org/m2/' }
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.3, 0.99.99]'
    classpath 'com.google.gms:google-services:4.3.0'
    classpath 'io.fabric.tools:gradle:1.26.1'
}

app.build.gradle

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

dependencies {
   implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
   testImplementation 'junit:junit:4.12'
   androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
   androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
   implementation 'com.android.support:multidex:1.0.3'
   implementation 'com.onesignal:OneSignal:[3.11.2, 3.99.99]'
}

apply plugin: 'io.fabric'
apply plugin: 'com.google.gms.google-services'

Flutter run is not working

Environment

  • Mac OS Catalina 10.15.1
  • Android Studio 3.5.2
  • Android emulator Pixel 3XL
  • Anything else:

    Build errors
    ```FAILURE: Build failed with an exception.

    • What went wrong:
      Could not determine the dependencies of task ':app:preDevDebugBuild'.

      Could not resolve all task dependencies for configuration ':app:devDebugCompileClasspath'.
      Could not resolve com.google.android.gms:play-services-base:[15.0.0, 16.0.0).
      Required by:
      project :app > com.onesignal:OneSignal:3.12.2
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Could not resolve com.google.android.gms:play-services-base:[15.0.1,16.0.0).
      Required by:
      project :app > com.google.android.gms:play-services-location:15.0.1
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Could not resolve com.google.android.gms:play-services-basement:[15.0.1,16.0.0).
      Required by:
      project :app > com.google.android.gms:play-services-location:15.0.1
      project :app > com.google.android.gms:play-services-places-placereport:15.0.1
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Could not resolve com.google.android.gms:play-services-tasks:[15.0.1,16.0.0).
      Required by:
      project :app > com.google.android.gms:play-services-location:15.0.1
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error
      Skipped due to earlier error

    • 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 22s
    Finished with error: Gradle task assembleDevDebug failed with exit code 1```

    Compatibility Issue

    Most helpful comment

    same problem here. as a temporary workaround i put onesignal-gradle-plugin after flutter.gradle and before google-services:

    app.build.gradle

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

    funciona de momento...
    works for now

    All 12 comments

    I'm having this same issue on Android

    you can use this temporary workaround by downgrading com.google.gms:google-services to 4.1.0

    dependencies {
            classpath 'com.google.gms:google-services:4.1.0'
    }
    

    I'll give this a try

    you can use this temporary workaround by downgrading com.google.gms:google-services to 4.1.0

    dependencies {
    classpath 'com.google.gms:google-services:4.1.0'
    }

    Tried it. Doesn't help.

    Same here

    try adding

    dependencies {
            classpath 'com.google.gms:google-services:4.1.0'
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
    
    }
    

    also add this in app/build.gradle

    dependencies {
         implementation 'com.onesignal:OneSignal:[3.11.2, 3.99.99]'
    }
    

    try adding

    dependencies {
            classpath 'com.google.gms:google-services:4.1.0'
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
    
    }
    

    also add this in app/build.gradle

    dependencies {
         implementation 'com.onesignal:OneSignal:[3.11.2, 3.99.99]'
    }
    

    It didn't worked for me. Any one else solved the issue?

    try adding

    dependencies {
            classpath 'com.google.gms:google-services:4.1.0'
            classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.1, 0.99.99]'
    
    }
    

    also add this in app/build.gradle

    dependencies {
         implementation 'com.onesignal:OneSignal:[3.11.2, 3.99.99]'
    }
    

    Sadly, the workaround is not working.

    We are investigating. Thanks for your patience

    In the meantime, change the minimum version of the gradle plugin to the latest. This will force use of the newest version

    same problem here. as a temporary workaround i put onesignal-gradle-plugin after flutter.gradle and before google-services:

    app.build.gradle

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

    same problem here. as a temporary workaround i put onesignal-gradle-plugin after flutter.gradle and before google-services:

    app.build.gradle

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

    funciona de momento...
    works for now

    Howdy y'all,
    Thanks for your workaround Denis.

    Gracias Baldomero.

    Will close for now

    Was this page helpful?
    0 / 5 - 0 ratings