解析失败:com.firebase:firebase-jobdispatcher:0.5.0

Failed to resolve: com.firebase:firebase-jobdispatcher:0.5.0

我正在尝试构建项目,但这是我收到的错误消息。

    Error:(32, 13) Failed to resolve: com.firebase:firebase-jobdispatcher:0.5.0
    Show in File
    Show in Project Structure dialog

    Error:Failed to resolve: com.android.databinding:compiler:2.2.3
    Open File
    Show in Project Structure dialog

这是应用模块的构建文件:-

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion '24.0.0'

defaultConfig {
    applicationId "com.example.android.sunshine"
    minSdkVersion 10
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
    }
}

dataBinding.enabled = true
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:24.2.1'

compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.android.support:preference-v7:24.2.1'

compile 'com.android.support.constraint:constraint-layout:1.0.0-beta3'

compile 'com.firebase:firebase-jobdispatcher:0.5.0'

// Instrumentation dependencies use androidTestCompile
// (as opposed to testCompile for local unit tests run in the JVM)
androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:24.2.1'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
}

这里是完整项目模块的构建文件:-

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
String osName = System.getProperty("os.name").toLowerCase();
if (osName.contains("windows")) {
    buildDir = "C:/tmp/${rootProject.name}/${project.name}"
}
repositories {
    jcenter()
}
}

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

这是 AndroidManifest.xml 文件:-

    <?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright (C) 2016 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.-->
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.sunshine">

    <!-- This permission is necessary in order for Sunshine to perform network access. -->
    <uses-permission android:name="android.permission.INTERNET"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <!--The manifest entry for our MainActivity. Each Activity requires a manifest entry-->
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:launchMode="singleTop"
            android:theme="@style/AppTheme.Forecast">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <!--The manifest entry for our DetailActivity. Each Activity requires a manifest entry-->
        <activity
            android:name=".DetailActivity"
            android:label="@string/title_activity_detail"
            android:parentActivityName=".MainActivity"
            android:theme="@style/AppTheme">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity"/>
        </activity>

        <!--The manifest entry for our SettingsActivity. Each Activity requires a manifest entry-->
        <activity android:name=".SettingsActivity"/>

        <!-- Our ContentProvider -->
        <provider
            android:name=".data.WeatherProvider"
            android:authorities="@string/content_authority"
            android:exported="false"/>

        <!--This is required for immediate syncs -->
        <service
            android:name=".sync.SunshineSyncIntentService"
            android:exported="false" />

        <!-- This is the Service declaration used in conjunction with FirebaseJobDispatcher -->
        <service
            android:name=".sync.SunshineFirebaseJobService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.firebase.jobdispatcher.ACTION_EXECUTE"/>
            </intent-filter>
        </service>

    </application>
</manifest>

我该如何解决这个问题?我在互联网上也没有资源。

它在图书馆的 github:

中提到

If you don't have a dependency on com.google.android.gms:play-services-gcm, add the following to your build.gradle's dependencies section:

compile 'com.firebase:firebase-jobdispatcher:0.5.2'

Otherwise add the following:

compile 'com.firebase:firebase-jobdispatcher-with-gcm-dep:0.5.2'

而且我在您的 gradle 文件中没有看到任何对 gms 的依赖。所以你应该使用第二个依赖项。

更新(2017 年 5 月):第二个依赖项已从文档中删除。它现在应该仅适用于此依赖项: compile 'com.firebase:firebase-jobdispatcher:0.5.2'.