无法解决实施-Android

时间:2019-01-15 10:42:41

标签: android android-studio android-gradle android-library

我有波纹管错误,我进行了搜索,但找不到任何答案:

Failed to resolve: play-services-measurement-api

Failed to resolve: firebase-analytics-impl

Failed to resolve: firebase-iid

Failed to resolve: play-services-measurement-base

这是我的build.gradle

buildscript {
    apply from: rootProject.file('dependencies.gradle')
    repositories {
        google()
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:${versions.dokka}"
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'io.fabric.tools:gradle:1.25.4'

        classpath "com.github.ben-manes:gradle-versions-plugin:0.20.0"

        classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc3'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://jitpack.io" }
    }

    apply from: rootProject.file('dependencies.gradle')
}

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

我有:

ext {
    versions = [
            // For project configuration
            java                  : JavaVersion.VERSION_1_8,
            compileSdk            : 28,
            targetSdk             : 28,
            minSdk                : 21,
            buildTools            : '28.0.3',
            dokka                 : '0.9.16',

            // For app
            kotlin                : '1.2.71',
            coroutine             : '0.25.0',

            appCompat             : '1.0.0',
            recyclerview          : '1.0.0',
            constraintLayout      : '2.0.0-alpha2',
            cardview              : '1.0.0',
            browser               : '1.0.0',
            androidKtx            : '1.0.0',
            workmanager           : '1.0.0-alpha09',

            dagger                : '2.16',
            firebaseCloudMessage  : '17.3.4',
            firebaseAnalytics     : '16.0.6',
            playServices          : '16.0.1',
            exoPlayer             : '2.8.2',
            flexbox               : '1.1.0',
            material              : '1.0.0',

            room                  : '2.0.0',
            lifecycle             : '2.0.0',

            livedataKtx           : '2.0.1',

            rxKotlin              : '2.3.0',
            rxAndroid             : '2.1.0',

            moshi                 : '1.6.0',
            okhttp                : '3.11.0',

            timber                : '4.7.1',
            threeTenABP           : '1.1.0',
            rxBinding             : '2.1.1',

            fresco                : '1.10.0',

            kotshi                : '1.0.4',

            frescoImageViewer     : '0.5.1',
            markwon               : '2.0.0',
            aVLoadingIndicatorView: '2.1.3',
            glide                 : '4.8.0',

            // For wearable
            wear                  : '2.3.0',
            playServicesWearable  : '15.0.1',
            supportWearable       : '27.1.1',

            // For testing
            junit                 : '4.12',
            truth                 : '0.42',
            espresso              : '3.1.0-alpha4',
            mockito               : '2.21.0'
    ]
    libraries = [
            kotlin                : "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}",
            coroutines            : "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.coroutine}",
            coroutinesAndroid     : "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.coroutine}",

            appCompat             : "androidx.appcompat:appcompat:${versions.appCompat}",
            recyclerview          : "androidx.recyclerview:recyclerview:${versions.recyclerview}",
            constraintlayout      : "androidx.constraintlayout:constraintlayout:${versions.constraintLayout}",
            cardview              : "androidx.cardview:cardview:${versions.cardview}",
            browser               : "androidx.browser:browser:${versions.browser}",
            androidKtx            : "androidx.core:core-ktx:${versions.androidKtx}",
            fragmentsKtx          : "androidx.fragment:fragment-ktx:${versions.androidKtx}",
            workmanager           : "android.arch.work:work-runtime-ktx:${versions.workmanager}",
            workmanagerFirebase   : "android.arch.work:work-firebase:${versions.workmanager}",

            dagger                : "com.google.dagger:dagger:${versions.dagger}",
            daggerSupport         : "com.google.dagger:dagger-android-support:${versions.dagger}",
            daggerProcessor       : "com.google.dagger:dagger-compiler:${versions.dagger}",
            daggerAndroidApt      : "com.google.dagger:dagger-android-processor:${versions.dagger}",
            exoPlayer             : "com.google.android.exoplayer:exoplayer:${versions.exoPlayer}",
            flexbox               : "com.google.android:flexbox:${versions.flexbox}",
            material              : "com.google.android.material:material:${versions.material}",

            room                  : "androidx.room:room-runtime:${versions.room}",
            roomProcessor         : "androidx.room:room-compiler:${versions.room}",
            lifecycleExtensions   : "androidx.lifecycle:lifecycle-extensions:${versions.lifecycle}",
            lifecycleCompiler     : "androidx.lifecycle:lifecycle-compiler:${versions.lifecycle}",
            viewmodelKtx          : "androidx.lifecycle:lifecycle-viewmodel-ktx:${versions.lifecycle}",

            livedataKtx           : "com.shopify:livedata-ktx:${versions.livedataKtx}",

            rxKotlin              : "io.reactivex.rxjava2:rxkotlin:${versions.rxKotlin}",
            rxAndroid             : "io.reactivex.rxjava2:rxandroid:${versions.rxAndroid}",

            moshi                 : "com.squareup.moshi:moshi:${versions.moshi}",
            moshiKotlin           : "com.squareup.moshi:moshi-kotlin:${versions.moshi}",
            okhttp                : "com.squareup.okhttp3:okhttp:${versions.okhttp}",
            okhttpLogger          : "com.squareup.okhttp3:logging-interceptor:${versions.okhttp}",

            timber                : "com.jakewharton.timber:timber:${versions.timber}",
            threeTenABP           : "com.jakewharton.threetenabp:threetenabp:${versions.threeTenABP}",
            rxBinding             : "com.jakewharton.rxbinding2:rxbinding-kotlin:${versions.rxBinding}",

            fresco                : "com.facebook.fresco:fresco:${versions.fresco}",
            frescoOkHttp          : "com.facebook.fresco:imagepipeline-okhttp3:${versions.fresco}",
            frescoAnimatedGif     : "com.facebook.fresco:animated-gif:${versions.fresco}",
            frescoWebP            : "com.facebook.fresco:webpsupport:${versions.fresco}",
            frescoAnimatedWebP    : "com.facebook.fresco:animated-webp:${versions.fresco}",

            kotshiApi             : "se.ansman.kotshi:api:${versions.kotshi}",
            kotshiCompiler        : "se.ansman.kotshi:compiler:${versions.kotshi}",

            frescoImageViewer     : "com.github.luciofm:FrescoImageViewer:${versions.frescoImageViewer}",
            glide                 : "com.github.bumptech.glide:glide:${versions.glide}",
            glideProcessor        : "com.github.bumptech.glide:compiler:${versions.glide}",

            markwon               : "ru.noties:markwon:${versions.markwon}",

            aVLoadingIndicatorView: "com.wang.avi:library:${versions.aVLoadingIndicatorView}",

            // Proprietary libraries
            fcm                   : "com.google.firebase:firebase-messaging:${versions.firebaseCloudMessage}",
            firebaseAnalytics     : "com.google.firebase:firebase-core:${versions.firebaseAnalytics}",
            playServicesAuth      : "com.google.android.gms:play-services-auth:${versions.playServices}",

            // For wearable
            wearable              : "com.google.android.support:wearable:${versions.wear}",
            playServicesWearable  : "com.google.android.gms:play-services-wearable:${versions.playServicesWearable}",
            percentLayout         : "com.android.support:percent:${versions.supportWearable}",
            supportWearable       : "com.android.support:support-v4:${versions.supportWearable}",
            wearableRecyclerView  : "com.android.support:recyclerview-v7:${versions.supportWearable}",
            wearSupport           : "com.android.support:wear:${versions.supportWearable}",

            // For testing
            junit                 : "junit:junit:${versions.junit}",
            espressoCore          : "androidx.test.espresso:espresso-core:${versions.espresso}",
            espressoIntents       : "androidx.test.espresso:espresso-intents:${versions.espresso}",
            roomTest              : "android.arch.persistence.room:testing:${versions.room}",
            truth                 : "com.google.truth:truth:${versions.truth}"
    ]
}

我的google library版本是最新版本,但不起作用。

我在做下面的工作:

  • 重新启动项目
  • 无效并重新启动
  • 清理并构建
  • 等...
  • 我正在从google()等库中使用库,但无法正常工作。
  • 重新启动插件
  • 我从android studio中删除了项目,然后添加了。

我该怎么办?

3 个答案:

答案 0 :(得分:0)

添加

buildscript {

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

到您的项目build.gradle

答案 1 :(得分:0)

更新

playServicesWearable  : '15.0.1',
supportWearable       : '27.1.1'

playServicesWearable  : '16.0.1',
supportWearable       : '1.0.0'

现在,替换

"com.android.support:wear:${versions.supportWearable}"

使用

"androidx.wear:wear:${versions.supportWearable}",

此外,添加此依赖项:

compileOnly 'com.google.android.wearable:wearable:2.3.0'
implementation 'com.google.firebase:firebase-auth:16.1.0'

然后删除

playServicesAuth      : "com.google.android.gms:play-services-auth:${versions.playServices}",

答案 2 :(得分:0)

解决了我的问题:

implementation 'com.google.android.gms:play-services-measurement-api:16.0.4'
implementation 'com.google.firebase:firebase-analytics-impl:16.2.4'
implementation 'com.google.android.gms:play-services-measurement-base:16.0.5'
implementation 'com.google.firebase:firebase-iid:17.0.4'