无法解决:com.firebase:firebase-jobdispatcher:0.5.0

时间:2017-02-09 14:21:40

标签: android firebase firebase-realtime-database firebase-storage mobile-development

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

    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

以下是app模块的构建文件: -

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>

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

1 个答案:

答案 0 :(得分:9)

在图书馆github上提及:

  

如果你不依赖   com.google.android.gms:play-services-gcm,将以下内容添加到您的   build.gradle的依赖项部分:

     

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

     

否则添加以下内容:

     

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

我在Gradle文件中看不到对gms的依赖。所以你应该使用第二个依赖。

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