Highest firebase version code is used for compilin

2019-02-19 13:57发布

I am using certain firebase and play services library in my project. After updating play services plugin version to 4.0.0. Since firebase and play services now use different version coding strategy for each library the highest version code in either one of them is replaced for all other libraries. Which results in unable to resolve the libraries which are still using lesser version codes.

build.gradle

    buildscript {

    ext.kotlin_version = '1.2.41'

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

app.gradle

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
//apply plugin: 'kotlin-kapt'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "com.vanse.android"
        minSdkVersion 19
        targetSdkVersion 27
        versionCode 1
        versionName "8.0"
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        manifestPlaceholders = [onesignal_app_id               : ONE_SIGNAL_APP_ID,
                                onesignal_google_project_number: "REMOTE"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    lintOptions {
        abortOnError false
    }
}
buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/' }
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
    }
}

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

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:support-vector-drawable:27.1.1'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.android.support:mediarouter-v7:27.1.1'

    //To upgrade dependency used in library picasso
    implementation 'com.android.support:exifinterface:27.1.1'
    //To upgrade dependency used in library OneSignal and Facebook
    implementation 'com.android.support:customtabs:27.1.1'
    //FireBase Dynamic Links
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation 'com.google.firebase:firebase-invites:16.0.0'
    implementation 'com.google.firebase:firebase-appindexing:15.0.1'
    implementation 'com.google.firebase:firebase-ads:16.0.0'

    //Google Sign In
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.google.android.gms:play-services-gcm:15.0.1'
    implementation 'com.google.android.gms:play-services-location:15.0.1'
    implementation 'com.google.android.gms:play-services-base:15.0.1'
    //ChromeCast
    implementation 'com.google.android.gms:play-services-cast-framework:15.0.1'
    //Download Manager
    implementation "com.tonyodev.fetch2:fetch2:2.0.0-RC19"
    implementation "com.tonyodev.fetch2downloaders:fetch2downloaders:2.0.0-RC19"
    implementation "com.tonyodev.fetch2rx:fetch2rx:2.0.0-RC19"
    implementation "com.tonyodev.fetchmigrator:fetchmigrator:2.0.0-RC19"
    //Kotlin Dependency
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //Network Calls
    implementation 'com.android.volley:volley:1.1.0'
    //JSON Parsing
    implementation 'com.google.code.gson:gson:2.8.2'
    //Push Notification
    implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
    //Image Loader
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    //Facebook SDK
    implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
    //Detect Memory leaks
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
    releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'

    //Image Loading library
    implementation 'com.squareup.picasso:picasso:2.71828'
    //Image Caching library
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    //For live radio wave layout
    implementation 'me.itangqi.waveloadingview:library:0.3.5'
    //For audio and video player
    implementation 'com.google.android.exoplayer:exoplayer:2.7.3'
    //For multipart file upload
    implementation 'com.koushikdutta.ion:ion:2.2.1'
    //pulse animation
    implementation 'pl.bclogic:pulsator4droid:1.0.3'
    //Payment Gateway
    implementation 'com.razorpay:checkout:1.4.7'

    implementation('io.socket:socket.io-client:1.0.0') {
        exclude group: 'org.json', module: 'json'
    }
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
//    kapt 'com.github.bumptech.glide:compiler:4.7.1'
    implementation files('libs/tokenautocomplete-2.0.8.jar')
}

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

ERROR

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':app:debugCompileClasspath'.
> Could not find com.google.firebase:firebase-appindexing:16.0.0.
  Required by:
      project :app
> Could not find com.google.firebase:firebase-ads:16.0.0.
  Required by:
      project :app
> Could not find com.google.android.gms:play-services-auth:16.0.0.
  Required by:
      project :app
> Could not find com.google.android.gms:play-services-gcm:16.0.0.
  Required by:
      project :app
> Could not find com.google.android.gms:play-services-location:16.0.0.
  Required by:
      project :app
> Could not find com.google.android.gms:play-services-base:16.0.0.
  Required by:
      project :app
      project :app > com.google.firebase:firebase-invites:16.0.0 > com.google.android.gms:play-services-appinvite:16.0.0
      project :app > com.google.firebase:firebase-invites:16.0.0 > com.google.android.gms:play-services-appinvite:16.0.0 > com.google.firebase:firebase-dynamic-links:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0 > com.google.firebase:firebase-iid:16.0.0 > com.google.firebase:firebase-iid-interop:16.0.0
> Could not find com.google.android.gms:play-services-cast-framework:16.0.0.
  Required by:
      project :app
> Could not find com.google.firebase:firebase-messaging:16.0.0.
  Required by:
      project :app > com.onesignal:OneSignal:3.9.1
> Could not find com.google.android.gms:play-services-location:16.0.0.
  Required by:
      project :app > com.onesignal:OneSignal:3.9.1
> Could not find com.google.android.gms:play-services-base:16.0.0.
  Required by:
      project :app > com.onesignal:OneSignal:3.9.1
> Could not find com.google.android.gms:play-services-basement:16.0.0.
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-measurement-connector-impl:16.0.0
      project :app > com.google.firebase:firebase-invites:16.0.0 > com.google.android.gms:play-services-appinvite:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-common:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-measurement-connector-impl:16.0.0 > com.google.firebase:firebase-measurement-connector:16.0.0
      project :app > com.google.firebase:firebase-invites:16.0.0 > com.google.android.gms:play-services-appinvite:16.0.0 > com.google.firebase:firebase-dynamic-links:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0 > com.google.firebase:firebase-iid:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0 > com.google.firebase:firebase-iid:16.0.0 > com.google.firebase:firebase-iid-interop:16.0.0
> Could not find com.google.android.gms:play-services-measurement-base:16.0.0.
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-measurement-connector-impl:16.0.0
      project :app > com.google.firebase:firebase-invites:16.0.0 > com.google.android.gms:play-services-appinvite:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0
      project :app > com.google.firebase:firebase-invites:16.0.0 > com.google.android.gms:play-services-appinvite:16.0.0 > com.google.firebase:firebase-dynamic-links:16.0.0
> Could not find com.google.android.gms:play-services-stats:16.0.0.
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0 > com.google.firebase:firebase-iid:16.0.0
> Could not find com.google.android.gms:play-services-tasks:16.0.0.
  Required by:
      project :app > com.google.firebase:firebase-invites:16.0.0 > com.google.android.gms:play-services-appinvite:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-common:16.0.0
      project :app > com.google.firebase:firebase-invites:16.0.0 > com.google.android.gms:play-services-appinvite:16.0.0 > com.google.firebase:firebase-dynamic-links:16.0.0
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0 > com.google.firebase:firebase-iid:16.0.0
> Could not find com.google.android.gms:play-services-ads-identifier:16.0.0.
  Required by:
      project :app > com.google.firebase:firebase-core:16.0.0 > com.google.firebase:firebase-analytics:16.0.0 > com.google.firebase:firebase-analytics-impl:16.0.0

* 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 36s

2条回答
劫难
2楼-- · 2019-02-19 14:01

This part of the error seems to indicate the Gradle plugin you're using (com.onesignal.androidsdk.onesignal-gradle-plugin) has a bug or you need a newer version.

Could not find com.google.firebase:firebase-appindexing:16.0.0. Required by: project :app

https://maven.google.com indicates that this library isn't released (at this point in time). Independently, I can definitively tell you that the library hasn't be released at that version.

Here's the plugin source showing special casing around our v15.x.x releases which (again either has a bug or you need a newer version). https://github.com/OneSignal/OneSignal-Gradle-Plugin/blob/master/src/main/groovy/com/onesignal/androidsdk/GradleProjectPlugin.groovy#L293

If you remove the plugin I think you'll see your app stops trying to find the 16.0.0 libraries that weren't published.

查看更多
做个烂人
3楼-- · 2019-02-19 14:23

for anyone who came here and having the same problem, I've downgrade the Firebase version from 16.0.1 to 15.0.0 which is the same with

com.google.android.gms:play-services-maps:15.x.x

and upgraded the OneSignal plugin to the latest and it works fine, also if anyone ran into another error when you trying to run the project an error might occur with this warning:

AGPBI: {"kind":"error","text":"Program type already present: android.support.design.widget.CoordinatorLayout$Behavior","sources":[{}],"tool":"D8"}

if so please add this line in your dependencies:

implementation 'com.android.support:design-v7:27.1.0'

also use the EXACT version i did here, otherwise you will ran into problem

other things you should check:

    classpath 'com.android.tools.build:gradle:3.1.0'
    classpath 'com.google.gms:google-services:3.0.0'

hope it helps because it got me for 2 days, and feel free to ask more. happy coding

查看更多
登录 后发表回答