无法将Firestore添加到我的项目

时间:2018-06-18 14:15:37

标签: android firebase google-cloud-firestore

当我试图将firestore添加到我的project.it开始向我显示依赖性error.i试图更改与相同版本相关的每个firebase的版本。它显示无法下载.jar files.some一个帮助我排除这个out.i包括maven url也没有用.... enter code here

我不知道如何手动添加这些jar文件。有什么方法可以解决这个问题。所以这些文件会自动下载。谢谢提前

错误:

app/build.gradle    
Unable to resolve dependency for ':app@debug/compileClasspath': Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)">Show Details</a>  
Unable to resolve dependency for ':app@debug/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)">Show Details</a>    
Unable to resolve dependency for ':app@debug/compileClasspath': Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)">Show Details</a>  
Unable to resolve dependency for ':app@debug/compileClasspath': Could not download guava.jar (com.google.guava:guava:19.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download guava.jar (com.google.guava:guava:19.0)">Show Details</a>  
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)">Show Details</a>   
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)">Show Details</a> 
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)">Show Details</a>   
Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download guava.jar (com.google.guava:guava:19.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download guava.jar (com.google.guava:guava:19.0)">Show Details</a>   
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)">Show Details</a>  
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)">Show Details</a>    
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)">Show Details</a>  
Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download guava.jar (com.google.guava:guava:19.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download guava.jar (com.google.guava:guava:19.0)">Show Details</a>  
Unable to resolve dependency for ':app@release/compileClasspath': Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)">Show Details</a>    
Unable to resolve dependency for ':app@release/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)">Show Details</a>  
Unable to resolve dependency for ':app@release/compileClasspath': Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)">Show Details</a>    
Unable to resolve dependency for ':app@release/compileClasspath': Could not download guava.jar (com.google.guava:guava:19.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Could not download guava.jar (com.google.guava:guava:19.0)">Show Details</a>    
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Could not download grpc-core.jar (io.grpc:grpc-core:1.8.0)">Show Details</a>    
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Could not download okhttp.jar (com.squareup.okhttp:okhttp:2.7.2)">Show Details</a>  
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not download protobuf-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/buil`d.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Could not download protobu`f-lite.jar (com.google.protobuf:protobuf-lite:3.0.1)">Show Details</a>  
Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not download guava.jar (com.google.guava:guava:19.0)
<a href="openFile:C:/Users/Sarukesi/AndroidStudioProjects/Seminarbook/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Could not download guava.jar (com.google.guava:guava:19.0)">Show Details</a>    

的build.gradle:

//noinspection GradleDependency
apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.sarukesi.seminarbook"
        minSdkVersion 15
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-auth:16.0.1'
    implementation 'junit:junit:4.12'
    implementation 'com.android.support.test:runner:1.0.2'
    implementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    implementation 'com.google.firebase:firebase-firestore:17.0.1'
}

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

3 个答案:

答案 0 :(得分:2)

我已将 mavenCentral()添加到项目级别的build.gradle文件中。 Gradle同步成功。

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

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.1'
        classpath 'com.google.gms:google-services:4.2.0'

        // 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
}

答案 1 :(得分:0)

确保您在项目中

点击

打开首选项
  • 文件&gt;设置(在Mac上,Android Studio&gt;偏好设置)
  • 在左侧窗格中,点击构建,执行,部署&gt;&gt;摇篮
  • 取消选中/禁用离线工作复选框
  • 单击“应用”或“确定”

答案 2 :(得分:0)

我尝试将appcompat版本从28降级到15.但错误仍然相同。所以我再次将其更改为28并从build.gradle文件中删除了该maven url,因为我在某处读取了google()是否存在因此我删除了那个。之后那些依赖错误会自动解决。最后gradle成功构建。感谢@giudigior和@AlexMamo回复......