无法解决所有Google依赖项

时间:2018-06-29 11:19:30

标签: android android-studio gradle

我在个人计算机上打开了我的工作项目,而Gradle构建无法解决所有Google依赖项(支持库,firebase,gms等),我的gradle文件中同时包含google()url "https://maven.google.com",经过多次尝试找出问题所在后,我实际上将其放置在任何可以找到的地方。 Gradle给我这个错误

Failed to resolve: cardview-v7
Open File

Failed to resolve: design
Open File

Failed to resolve: recyclerview-v7
Open File

Failed to resolve: percent
Open File

Failed to resolve: play-services-maps
Open File

Failed to resolve: firebase-messaging
Open File

Failed to resolve: firebase-invites
Open File

Failed to resolve: play-services-appinvite
Open File

Failed to resolve: firebase-analytics
Open File

Failed to resolve: firebase-iid-interop
Open File

Failed to resolve: firebase-common
Open File

Failed to resolve: play-services-tasks
Open File

Failed to resolve: firebase-measurement-connector
Open File    

Failed to resolve: play-services-stats
Open File    

Failed to resolve: support-v4
Open File

Failed to resolve: transition
Open File

Failed to resolve: appcompat-v7
Open File    

Failed to resolve: support-fragment
Open File

Failed to resolve: animated-vector-drawable
Open File

Failed to resolve: support-core-ui
Open File

Failed to resolve: support-vector-drawable
Open File

Failed to resolve: support-annotations
Open File

如果有人需要它们,我将发布我的gradle文件,知道这可能是什么吗?我的其他项目工作正常,只有这个有问题。同样是昨天,在我的工作计算机上,一切正常,并且之间没有更改代码

编辑

build.gradle(Project:MyApp)

apply plugin: 'com.github.ben-manes.versions'

buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        jcenter()
        google()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'

        classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
        classpath "io.realm:realm-gradle-plugin:4.3.0"
        classpath 'com.google.gms:google-services:3.2.1'


        classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io" }
    }
}

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

build.gradle(Module:app)

buildscript {
        repositories {
            jcenter()
            google()
            maven {
                url 'https://maven.fabric.io/public'
            }
        }

        dependencies {
            classpath 'io.fabric.tools:gradle:1.+'
        }
    }

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
apply from: '../dependencies.gradle'


android {

    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.app.app"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 30

        versionName "1.2.2"
        vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        signingConfig signingConfigs.config
    }
    buildTypes {
        debug {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    dataBinding {
        enabled = true
    }
    lintOptions {
        abortOnError false
    }
    testOptions {
        unitTests.returnDefaultValues = true
    }
    packagingOptions {
        // Remove unneeded Realm native libs (nearly no devices use these)
        exclude 'lib/mips/librealm-jni.so'
        // comment the following line out and clean project, if you want to
        // test the app in an emulator/x86 device
        //exclude 'lib/x86/librealm-jni.so'
        //exclude 'lib/x86_64/librealm-jni.so'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
}


repositories {
    jcenter()
    google()
    maven { url 'https://jitpack.io' }
    maven { url 'https://maven.fabric.io/public' }

    maven {
        url 'https://github.com/uPhyca/stetho-realm/raw/master/maven-repo'
    }
    maven {
        url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"
    }
    maven { url "https://api.bitbucket.org/1.0/repositories/touchartsro/maven-public/raw/releases" }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:multidex:1.0.3'
    annotationProcessor "com.google.dagger:dagger-compiler:${daggerVersion}"
    implementation "com.google.dagger:dagger:${daggerVersion}"    

    implementation 'com.android.support.constraint:constraint-layout:1.0.2'

    implementation "com.android.support:cardview-v7:${supportLibVersion}"
    implementation "com.android.support:appcompat-v7:${supportLibVersion}"
    implementation "com.android.support:cardview-v7:${supportLibVersion}"
    implementation "com.android.support:recyclerview-v7:${supportLibVersion}"
    implementation "com.android.support:design:${supportLibVersion}"
    implementation "com.android.support:percent:${supportLibVersion}"
    implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}"
    implementation "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
    implementation "com.squareup.retrofit2:adapter-rxjava:${retrofitVersion}"
    implementation "com.squareup.okhttp3:okhttp:${okHttpVersion}"
    implementation "com.squareup.okhttp3:logging-interceptor:${okHttpVersion}"
    implementation 'io.realm:android-adapters:2.1.0'
    implementation "org.parceler:parceler-api:${parcelerVersion}"
    annotationProcessor "org.parceler:parceler:${parcelerVersion}"
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.0@aar') {
        transitive = true;
    }
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.jakewharton.timber:timber:4.6.0'
    implementation 'io.jsonwebtoken:jjwt:0.7.0'
    implementation('io.socket:socket.io-client:1.0.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
    implementation 'io.reactivex:rxjava:1.2.1'
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava-async-util:0.21.0'
    implementation 'com.jakewharton.rxbinding:rxbinding:0.3.0'
    implementation 'com.trello:rxlifecycle:0.4.0'
    implementation 'com.trello:rxlifecycle-components:0.4.0'
    implementation 'com.facebook.android:facebook-android-sdk:4.23.0'
    implementation 'org.twitter4j:twitter4j-core:4.0.4'
    implementation 'com.facebook.stetho:stetho:1.4.1'
    implementation 'com.uphyca:stetho_realm:2.1.0'
    implementation 'com.facebook.fresco:fresco:1.8.1'
    implementation 'com.facebook.fresco:animated-gif:1.5.0'
    implementation 'com.facebook.fresco:animated-webp:1.5.0'
    implementation 'com.facebook.fresco:webpsupport:1.5.0'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'
    implementation 'com.google.firebase:firebase-invites:16.0.0'
    implementation 'net.danlew:android.joda:2.9.9'
    implementation 'com.aurelhubert:ahbottomnavigation:2.2.0'
    implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
    implementation 'org.sufficientlysecure:html-textview:3.5'
    implementation 'com.github.mukeshsolanki:country-picker-android:1.1.9'
    implementation 'net.opacapp:multiline-collapsingtoolbar:1.5.0'
    implementation 'me.zhanghai.android.materialratingbar:library:1.1.0'
    implementation 'com.journeyapps:zxing-android-embedded:3.5.0'
    implementation 'me.postaddict:instagramscraper:1.0.0'


    implementation project(':card-fold')

    //implementation project(':fcell')
    //implementation project(':kotlin-utils')

    implementation 'cz.touchart:kotlin-utils:0.1.6'

    implementation 'com.github.bumptech.glide:glide:4.6.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
    compileOnly 'javax.annotation:jsr250-api:1.0'
}

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

build.gradle(模块:other_moduke)

buildscript {
    repositories {

        google()
        maven {
            url "https://maven.google.com"
        }
        jcenter()

    }
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply from: '../dependencies.gradle'

android {
    compileSdkVersion 27

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        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(dir: 'libs', include: ['*.jar'])

    implementation "com.android.support:appcompat-v7:$supportLibVersion"
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
}

dependencies.gradle

ext.kotlinVersion = '1.2.30'
ext.supportLibVersion = '27.1.0'

ext.retrofitVersion = '2.3.0'
ext.okHttpVersion = '3.8.1'
ext.daggerVersion = '2.11'
ext.parcelerVersion = '1.1.9'

3 个答案:

答案 0 :(得分:0)

实际上,您也必须拥有jcenter()。例如,我的顶级gradle如下所示:

buildscript {

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

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

根据您的等级进行编辑:

请勿将依赖项放在build.gradle (Project:MyApp)中。它们必须仅在模块中。将它们移至build.gradle (Module:app)

编辑2:您的代码:

implementation "com.android.support:cardview-v7:${supportLibVersion}"

您的supportLibVersion变量在哪里?

答案 1 :(得分:0)

从以下位置更新 google服务

classpath 'com.google.gms:google-services:3.2.1'

收件人:

classpath 'com.google.gms:google-services:4.0.1'

答案 2 :(得分:0)

经过多次尝试,我通过重新安装整个Android Studio来解决了此问题,我的本地gradle出了点问题(也许只是从/ AppData中删除.gradle之类的东西就足够了)。在重新安装的Android Studio中打开项目后,一切正常。

相关问题