首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >已存在的程序类型: com.google.common.annotations.GwtCompatible

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

Stack Overflow用户
提问于 2018-06-02 02:37:27
回答 2查看 1.3K关注 0票数 3

在构建我的android项目时,我得到了以下错误:

程序类型已经出现: com.google.common.annotations.GwtCompatible消息{kind=ERROR,text=Program类型已经出现: com.google.common.annotations.GwtCompatible,sources=Unknown源文件,工具name=Optional.of(D8)}

分级文件:

代码语言:javascript
复制
 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'

以下是解决这一问题的办法:

代码语言:javascript
复制
implementation ('com.google.cloud:google-cloud-language:1.31.0') { 
    exclude group: 'com.google.guava'
}

但是,我缺少了番石榴函数,因为运行时将引发以下错误:

没有找到"com.google.common.base.MoreObjects“类 原因: java.lang.NoClassDefFoundError:失败的解决方案:Lcom/google/ Failed /base/MoreObjects;

运行以下代码时: public void testSomething(视图视图){

代码语言:javascript
复制
    // Instantiate the Language client com.google.cloud.language.v1.LanguageServiceClient
        try {
            InputStream inputStream = getAssets().open("www.json");

            GoogleCredentials googleCredential = GoogleCredentials.fromStream(inputStream);
    }
    catch (Exception e){
        Log.e(TAG,e.getMessage());
        e.printStackTrace();
    }

我在这里绕圈。我很想找到答案。我检查了其他的问题/题目,没有对我有帮助的答案。

EN

回答 2

Stack Overflow用户

发布于 2018-07-30 14:25:28

我通过以下修改解决了同样的问题:

代码语言:javascript
复制
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'
}
票数 0
EN

Stack Overflow用户

发布于 2018-11-06 16:33:18

将Gradles改为:

代码语言:javascript
复制
implementation 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0'  exclude module: 'guava-jdk5'
    implementation 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'guava-jdk5' exclude module: 'httpclient'
    implementation 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'

这对我来说很管用

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50653030

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档