wmr*_*ice 57 android gradle maven android-studio annotation-processor
我正在尝试将maven存储库添加到我的Android Studio项目中.当我进行Gradle项目同步时,一切都很好.但是,每当我尝试构建我的apk时,我都会收到此错误:
Execution failed for task ':app:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now. The following dependencies on
the compile classpath are found to contain annotation processor. Please add them to
the annotationProcessor configuration.
- classindex-3.3.jar
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions
.includeCompileClasspath = true to continue with previous behavior. Note that this
option is deprecated and will be removed in the future.
See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.
Run Code Online (Sandbox Code Playgroud)
该链接包含(https://developer.android.com/r/tools/annotation-processor-error-message.html)错误404s所以它没有帮助.
我在android studio设置中启用了注释处理,并添加includeCompileClasspath = true到我的Annotation Processor选项中.我也曾尝试加入classindex,classindex-3.3并classindex-3.3.jar以处理器FQ名称,但没有帮助.
这些是我添加到dependecies下的默认build.gradle的行:
dependencies {
...
compile group: 'com.skadistats', name: 'clarity', version:'2.1.1'
compile group: 'org.atteo.classindex', name: 'classindex', version:'3.3'
}
Run Code Online (Sandbox Code Playgroud)
最初我只是添加了"清晰度",因为这是我关心的那个,但我添加了"classindex"条目,希望能解决它.删除"清晰度"并保持"classindex"给出了完全相同的错误.
我不太熟悉gradle/maven所以任何帮助都会受到赞赏.
Sno*_*man 84
要修复错误,只需更改这些依赖项的配置即可使用annotationProcessor.如果依赖项包含也需要在编译类路径上的组件,则再次声明该依赖项并使用编译依赖项配置.
例如:
annotationProcessor 'com.jakewharton:butterknife:7.0.1'
compile 'com.jakewharton:butterknife:7.0.1'
Run Code Online (Sandbox Code Playgroud)
此链接详细描述了它:https://developer.android.com/studio/preview/features/new-android-plugin-migration.html#annotationProcessor_config
包含完整性的相关代码段.
使用注释处理器依赖关系配置
在以前版本的Gradle Android插件中,编译类路径的依赖关系会自动添加到处理器类路径中.也就是说,您可以将一个注释处理器添加到编译类路径中,它将按预期工作.但是,这会通过向处理器添加大量不必要的依赖性而对性能产生重大影响.
使用新插件时,必须使用annotationProcessor依赖关系配置将注释处理器添加到处理器类路径中,如下所示:
依赖项{... annotationProcessor'com.google.dagger:dagger-compiler:'}
如果插件的JAR文件包含以下文件,则插件假定依赖关系是注释处理器:META- INF/services/javax.annotation.processing.Processor.如果插件检测到编译类路径上的注释处理器,则构建将失败,并且您将收到一条错误消息,其中列出了编译类路径上的每个注释处理器.要修复错误,只需更改这些依赖项的配置即可使用annotationProcessor.如果依赖项包含也需要在编译类路径上的组件,则再次声明该依赖项并使用编译依赖项配置.
小智 36
我遇到了类似的错误.我按照Google链接上的说明进行操作.
尝试将以下说明添加到您的应用程序gradle文件中:
defaultConfig {
applicationId "com.yourdomain.yourapp"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath false
}
}
}
Run Code Online (Sandbox Code Playgroud)
注意 - > includeCompileClasspath false
Ami*_*agh 21
将此代码添加到您的gradle应用程序
defaultConfig{
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在这里找到了解决方案https://github.com/JakeWharton/butterknife/issues/908
小智 11
只需使用Annotation处理器更新您的黄油刀
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
Run Code Online (Sandbox Code Playgroud)
我希望它对你有所帮助
| 归档时间: |
|
| 查看次数: |
51330 次 |
| 最近记录: |