构造不可变的类com时,发现字段“ rangeStart”的类型不受支持的类型(com.google.gms.googleservices.GoogleServicesPlugin $ Version)

时间:2018-11-14 07:20:44

标签: android firebase google-play-services

我将Android Studio的版本从3.3更新为3.4 Canary 3.4

我遇到了类似的错误

Unsupported type (com.google.gms.googleservices.GoogleServicesPlugin$Version) found
     for field 'rangeStart' while constructing immutable class com.google.gms.googleservices.GoogleServicesPlugin$VersionRange.
    Immutable classes only support properties with effectively immutable types including:

- Strings, primitive types, wrapper types, Class, BigInteger and BigDecimal, enums
- classes annotated with @KnownImmutable and known immutables (java.awt.Color, java.net.URI)
- Cloneable classes, collections, maps and arrays, and other classes with special handling
  (java.util.Date and various java.time.* classes and interfaces)
Other restrictions apply, please see the groovydoc for ImmutableOptions for further details

我正在使用classpath 'com.google.gms:google-services:4.0.2'apply plugin: 'com.google.gms.google-services'

我也遇到了这些错误

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-base:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-lite:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-gass:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-base:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-lite:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-gass:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-base:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-lite:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-gass:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-base:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-lite:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-gass:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@release/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-base:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-ads-lite:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-gass:[17.1.1].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-api:[16.0.3].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-measurement-base:[16.0.4].
Show Details
Affected Modules: app

ERROR: Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-analytics-impl:[16.2.3].
Show Details
Affected Modules: app 

帮助我解决这些错误,在此我被困住了,无法工作,谢谢。

编辑

这是我的应用模块的build.gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-kapt'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.xxx.xxx"
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 2
    versionName "1.0"

    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'


        resValue "string", "some_string", '"some value"'
    }

    debug {
        debuggable true

        resValue "string", "some_string", '"some value"'

    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
final SUPPORT_LIBRARY_VERSION = '28.0.0'
final PLAY_SERVICES_VERSION = '16.0.0'
final BUTTERKNIFE_VERSION = '8.8.1'

implementation fileTree(include: ['*.jar'], dir: 'libs')

implementation "com.jakewharton:butterknife:$BUTTERKNIFE_VERSION"
kapt "com.jakewharton:butterknife-compiler:$BUTTERKNIFE_VERSION"
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.github.anshulagarwal06:Simplify-Permissions:v1'


implementation "com.google.android.gms:play-services-location:$PLAY_SERVICES_VERSION"
implementation "com.google.android.gms:play-services-places:$PLAY_SERVICES_VERSION"

implementation "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:recyclerview-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:customtabs:$SUPPORT_LIBRARY_VERSION"
implementation "com.android.support:design:$SUPPORT_LIBRARY_VERSION"


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

implementation 'com.google.firebase:firebase-ads:17.1.1'
implementation 'com.google.firebase:firebase-core:16.0.5'


implementation 'com.squareup:otto:1.3.8'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.github.kobakei:MaterialFabSpeedDial:1.2.0'

implementation 'com.github.bumptech.glide:glide:3.6.0'
implementation 'com.caverock:androidsvg:1.2.1'


implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"


implementation 'com.nabinbhandari.android:permissions:3.5'
implementation 'org.greenrobot:eventbus:3.1.1'


implementation 'com.squareup.okhttp3:logging-interceptor:3.8.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'


implementation 'com.android.support:multidex:1.0.3'

implementation project(path: ':abc')
implementation project(path: ':xyz')
}


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

2 个答案:

答案 0 :(得分:0)

首先,我假设您使用的是4.1.0版(或4.0.0版)的google-services插件,但最新版本是4.2.0,它提供了许多有关冲突的传递依赖项。

因此,首先更新该内容:

classpath 'com.google.gms:google-services:4.2.0'(在root build.gradle或您有插件配置的任何位置)。

在那之后,您将获得有关冲突依赖关系的更多有用输出,诸如此类:

Dependency failing: com.google.android.gms:play-services-stats:15.0.1 -> com.google.android.gms:play-services-basement@[15.0.1], 
but play-services-basement version was 16.0.1.

The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the artifact with the issue.
-- Project 'app' depends onto com.google.firebase:firebase-common@16.0.0
...

BUILD FAILED IN X secs

帮助我的是,排除了play-services-locationplay-services-places的传递依赖项:

implementation("com.google.android.gms:play-services-maps:16.0.0") {
    exclude module: 'play-services-base'
    exclude module: 'play-services-basement'
    exclude module: 'play-services-tasks'
}

或者只是将用于位置和位置的库降级到15.0.1,这也可以解决问题。

答案 1 :(得分:-1)

尝试禁用离线工作->设置>等级>禁用离线工作