Java 在androidstudio中使用googletranslationapi
我正在尝试制作一个使用谷歌翻译API的应用程序。 自从我加上Java 在androidstudio中使用googletranslationapi,java,android,rest,google-translate,Java,Android,Rest,Google Translate,我正在尝试制作一个使用谷歌翻译API的应用程序。 自从我加上 compile 'com.google.cloud:google-cloud-translate:1.12.0' 对于build.gradle中的依赖项,我有一个错误: Error:Execution failed for task ':app:javaPreCompileDebug'. 现在必须显式声明注释处理器。发现编译类路径上的以下依赖项包含注释处理器。请将它们添加到annotationProcessor配置中。 -auto
compile 'com.google.cloud:google-cloud-translate:1.12.0'
对于build.gradle中的依赖项,我有一个错误:
Error:Execution failed for task ':app:javaPreCompileDebug'.
现在必须显式声明注释处理器。发现编译类路径上的以下依赖项包含注释处理器。请将它们添加到annotationProcessor配置中。
-auto-value-1.2.jar(com.google.auto.value:auto-value:1.2)
或者,设置android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath=true以继续前面的行为。请注意,此选项已弃用,将来将被删除。
有关更多详细信息,请参阅
然后我又加了一句
annotationProcessor 'com.google.auto.value:auto-value:1.2'
要删除build.gradle中的Dependencies,我遇到了以下错误:
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
发现多个文件具有独立于操作系统的路径“project.properties”
有人能帮我吗
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'
}
试试这个
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”的执行失败
放置
packagingOptions {
exclude 'project.properties'
exclude 'META-INF/INDEX.LIST'
}
gradle解决了这个问题。您可以共享依赖项{}块吗?当然可以。在这里。我仍然得到错误:任务执行失败“:app:transformResourcesWithMergeJavaResForDebug'>发现多个文件具有独立于操作系统的路径“project.properties”
packagingOptions {
exclude 'project.properties'
exclude 'META-INF/INDEX.LIST'
}