【问题标题】:Failed to resolve firebase-messaging and common - Android无法解决 firebase-messaging 和 common - Android
【发布时间】:2018-06-09 04:45:39
【问题描述】:

我在构建项目时遇到此错误。

  1. 未能解决:firebase-messaging
  2. 无法解决:常见

我在 stackoverflow 上没有得到任何解决方案。请检查代码并让我知道问题所在。

将项目导入 Android Studio 后出现此问题。

build.gradle

plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.8.1'
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    //buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "com.abcd.xyzzz"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 3
        versionName "1.0.2"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        manifestPlaceholders = [onesignal_app_id : "65f1XXXXXXXXc4-9e41-XXX",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "916298XXXXXXXX"]
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    // applovin
    implementation project(':unity-ads')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    implementation 'com.android.support:support-vector-drawable:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.jackpocket:scratchoff:1.1.0'
    implementation 'com.adcolony:sdk:3.2.1'
    implementation 'com.android.support:support-annotations:27.1.1'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'
    implementation 'com.android.support:cardview-v7:26.1.0'
    implementation 'com.facebook.android:facebook-share:4.33.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.ironsource.sdk:mediationsdk:6.7.0.1@jar'
    //compile 'com.google.ads.mediation:unity:2.1.1.0' //not used
    implementation 'com.google.firebase:firebase-database:11.6.0'
    implementation 'com.github.bumptech.glide:glide:4.1.1'
    implementation 'com.google.firebase:firebase-auth:11.6.0'
    implementation 'com.google.firebase:firebase-core:11.6.0'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.onesignal:OneSignal:[3.7.1, 3.9.1]'
    implementation files('libs/applovin-sdk-7.7.0-javadoc.jar')
    implementation files('libs/applovin-sdk-7.7.0.jar')
}
apply plugin: 'com.google.gms.google-services'

build.gradle(项目)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
        google()
        maven {
            url "https://maven.google.com"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0-alpha17'
        classpath 'com.google.gms:google-services:4.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
        maven { url "https://jitpack.io" }
        maven { url "https://adcolony.bintray.com/AdColony" }
        maven { url "https://dl.bintray.com/ironsource-mobile/android-sdk" }
        google()
    }
}

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

【问题讨论】:

    标签: android firebase firebase-realtime-database android-gradle-plugin firebase-authentication


    【解决方案1】:

    要解决这个问题,请更改以下代码行:

    implementation 'com.google.firebase:firebase-database:11.6.0'
    implementation 'com.google.firebase:firebase-auth:11.6.0'
    implementation 'com.google.firebase:firebase-core:11.6.0'
    

    implementation 'com.google.firebase:firebase-database:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.0'
    

    为了使用 Firebase Cloud Messaging,您需要添加相应的依赖项。所以也请添加这行新代码:

    implementation 'com.google.firebase:firebase-messaging:17.0.0'
    

    更多信息请参见here

    【讨论】:

    • 试过了......但更改版本后出现更多错误
    • @AlexMamo 不是所有与 firebase 相关的服务的版本都应该相同吗?
    • @sHOLE 不,不再是了。
    • @sHOLE 请查看here,您可以在其中找到所有最新版本。干杯!
    • @AlexMamo 会的。谢谢。
    猜你喜欢
    • 2018-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-30
    • 1970-01-01
    • 2020-06-22
    • 2023-04-10
    • 1970-01-01
    相关资源
    最近更新 更多