代码之家  ›  专栏  ›  技术社区  ›  TheJudge

无法解析所有谷歌依赖项

  •  0
  • TheJudge  · 技术社区  · 7 年前

    我在我的个人电脑上打开了我的工作项目,Gradle Build在解决所有谷歌依赖项(支持libs、Firebase、GMS等)时失败,我两者都有 google() url "https://maven.google.com" 在我的毕业档案里,我实际上放在任何一个我能找到的地方,在多次试图找出什么是错的。格雷德给了我这个错误

    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
    

    如果有人需要我的毕业档案,我会把它们寄出去,知道这是什么吗?我的其他项目都很好,只有这一个有问题。昨天在我的工作电脑上一切都很好,而且在

    编辑

    build.gradle(项目: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(模块: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(模块:其他模块)

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

    依赖关系.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 回复  |  直到 7 年前
        1
  •  0
  •   Paraskevas Ntsounos Charith Lakshitha    7 年前

    更新 谷歌服务 发件人:

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

    致:

    classpath 'com.google.gms:google-services:4.0.1'
    
        2
  •  0
  •   Alexander Tumanin    7 年前

    实际上你必须 jcenter() 也。例如,我的顶级毕业生看起来像:

    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 变数?

        3
  •  0
  •   TheJudge    7 年前

    在多次尝试之后,我通过重新安装整个android工作室解决了这个问题,我的本地gradle出了问题(可能只删除/appdata中的.gradle或类似的东西就足够了)。在重新安装的android工作室中打开项目后,一切正常。

    推荐文章