首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Android中使用

在Android中使用
EN

Stack Overflow用户
提问于 2017-11-22 12:41:48
回答 2查看 906关注 0票数 2

我正在尝试制作一个应用程序,它使用谷歌翻译API。因为我增加了

代码语言:javascript
复制
compile 'com.google.cloud:google-cloud-translate:1.12.0'

在我的build.gradle中出现了一个错误:

代码语言:javascript
复制
Error:Execution failed for task ':app:javaPreCompileDebug'.

注释处理器必须立即显式声明。编译类路径上的下列依赖项包含注释处理器。请将它们添加到annotationProcessor配置中。-auto 1.2.jar(com.google.auto.value:auto:1.2),将android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true设置为继续先前的行为。请注意,此选项已被取消,并将在将来删除。有关更多详细信息,请参阅https://developer.android.com/r/tools/annotation-processor-error-message.html

然后我也加入了

代码语言:javascript
复制
annotationProcessor 'com.google.auto.value:auto-value:1.2'

对于build.gradle中的依赖项,我得到了以下错误:

代码语言:javascript
复制
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

找到了多个与操作系统无关的路径“project.properties”的文件

这里有人能帮我吗?

代码语言:javascript
复制
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    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'
    compile 'com.google.cloud:google-cloud-translate:1.12.0'
    annotationProcessor 'com.google.auto.value:auto-value:1.2'
}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-11-27 11:58:55

推杆

代码语言:javascript
复制
packagingOptions {
            exclude 'project.properties'
            exclude 'META-INF/INDEX.LIST'
        }

我的build.gradle解决了这个问题。

票数 3
EN

Stack Overflow用户

发布于 2017-11-22 13:04:51

尝尝这个。

代码语言:javascript
复制
compile('com.google.cloud:google-cloud-translate:1.12.0') {
    exclude module: 'httpclient' //by artifact name
    exclude group: 'org.apache.httpcomponents' //by group
    exclude group: 'com.google.code.findbugs'
    exclude group: 'org.json', module: 'json'
}

它解决了我的问题。

编辑

将此添加到依赖项{}块之前。

为了解决

错误:任务':app:transformResourcesWithMergeJavaResForDebug'.执行失败

代码语言:javascript
复制
packagingOptions {
  exclude 'META-INF/NOTICE' // will not include NOTICE file
  exclude 'META-INF/LICENSE' // will not include LICENSE file
  // as noted by @Vishnuvathsan you may also need to include
  // variations on the file name. It depends on your dependencies.
  // Some other common variations on notice and license file names
  exclude 'META-INF/notice'
  exclude 'META-INF/notice.txt'
  exclude 'META-INF/license'
  exclude 'META-INF/license.txt'
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47435023

复制
相关文章

相似问题

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