Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/353.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 程序类型已存在:com.google.common.annotations.GwtCompatible_Java_Android_Android Studio - Fatal编程技术网

Java 程序类型已存在:com.google.common.annotations.GwtCompatible

Java 程序类型已存在:com.google.common.annotations.GwtCompatible,java,android,android-studio,Java,Android,Android Studio,我在构建android项目时遇到以下错误: 程序类型已存在: com.google.common.annotations.GwtCompatible消息{kind=ERROR, text=程序类型已存在: com.google.common.annotations.GwtCompatible,sources=[未知源代码] 文件],工具名称=可选.of(D8)} 渐变文件: apply plugin: 'com.android.application' android {

我在构建android项目时遇到以下错误:

程序类型已存在: com.google.common.annotations.GwtCompatible消息{kind=ERROR, text=程序类型已存在: com.google.common.annotations.GwtCompatible,sources=[未知源代码] 文件],工具名称=可选.of(D8)}

渐变文件:

 apply plugin: 'com.android.application'

    android {
        compileSdkVersion 27
        defaultConfig {
            applicationId "com.example.www.www"
            minSdkVersion 15
            targetSdkVersion 27
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

            // multi-dex support (When your app and the libraries it references exceed 65,536 methods)
            multiDexEnabled true
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
        packagingOptions {
            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'
            exclude 'META-INF/INDEX.LIST'
        }
    }

    dependencies {
        // multi-dex support (When your app and the libraries it references exceed 65,536 methods)
        implementation 'com.android.support:multidex:1.0.3'


        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.0'
        implementation 'com.android.support:design:27.1.1'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'com.android.support.test:runner:1.0.2'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'


        //this is for the google "text recognizer"
        implementation 'com.google.android.gms:play-services-vision:15.0.2'
        implementation 'com.google.apis:google-api-services-customsearch:v1-rev63-1.23.0'


        //for firebase database connection
        implementation 'com.google.firebase:firebase-database:16.0.1'
        //implementation 'com.google.firebase:firebase-core:16.0.0'
        // for firebase authentication
        implementation 'com.google.firebase:firebase-auth:16.0.1'
        implementation 'com.google.android.gms:play-services-auth:15.0.1'


        // for Google Natural Language Processing (part of google cloud services)
        implementation ('com.google.cloud:google-cloud-language:1.31.0')
              //  {
              //      exclude group: 'com.google.guava'
              //  }

    }


    apply plugin: 'com.google.gms.google-services'
以下内容解决了该问题:

implementation ('com.google.cloud:google-cloud-language:1.31.0') { 
    exclude group: 'com.google.guava'
}
但是我丢失了guava函数,因为在运行时会抛出以下错误:

未找到类“com.google.common.base.MoreObjects”

原因:java.lang.NoClassDefFoundError:解析失败: Lcom/google/common/base/MoreObjects

当我运行以下代码时: 公共void testSomething(视图){

我在这里兜圈子,我急切地想找到答案。
我检查了其他问题/主题,没有找到对我有帮助的答案。

我通过以下更改解决了相同的问题:

implementation ('com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'){
    exclude module: 'guava-jdk5'
}
implementation ('com.google.api-client:google-api-client-android:1.20.0'){
    exclude module: 'guava-jdk5'
}
将渐变更改为:
implementation'com.google.api:googleapi服务愿景:v1-rev369-1.23.0'排除模块:'guava-jdk5'
实现'com.google.api客户端:谷歌api客户端android:1.23.0'排除模块:'guava-jdk5'排除模块:'httpclient'

实现'com.google.http client:google http client gson:1.23.0'排除模块:'httpclient'
您解决了问题吗?
implementation ('com.google.apis:google-api-services-drive:v2-rev105-1.17.0-rc'){
    exclude module: 'guava-jdk5'
}
implementation ('com.google.api-client:google-api-client-android:1.20.0'){
    exclude module: 'guava-jdk5'
}