在Android Studio 3.0.1中,执行任务“:app:javaPreCompileDebug”失败。

5
当我尝试执行我的项目时,出现以下错误:
错误:任务“:app:javaPreCompileDebug”执行失败。 注释处理器现在必须显式声明。 在编译类路径上找到了以下依赖项 注释处理器。 请将它们添加到annotationProcessor配置中。 - butterknife-7.0.1.jar(com.jakewharton:butterknife:7.0.1)或者,设置 android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true以继续使用先前的行为。 请注意,此选项已过时,并将来被删除。 参见 {{link1:https://developer.android.com/r/tools/annotation-processor-error-message.html}} 获取更多详细信息。
请不要将此问题标记为重复,因为其他关于此问题的问题是关于lombok的,而我没有使用它。
3个回答

4

根据错误提示,您需要在应用程序 build.gradle 中使用 annotationProcessor。据我所知,您需要将 ButterKnife 库升级到版本8.8.1。您需要像这样使用:

dependencies {
  compile 'com.jakewharton:butterknife:8.8.1'
  annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}

请查看 Android studio 3.0 butterknife 错误问题的详细信息。

非常感谢您的建议。 我这样做了,然后我得到的错误是“无法解析符号Bind”。 在搜索时,我发现必须用'BindView'替换'Bind'。 我在所有活动中都这样做了。 然后我得到的错误是“找不到方法'getMap()”。 发现getMap()已被Google弃用,必须用getMapAsync()替换它。 现在我无法解决它,因为我不确定如何实现它。 错误涉及其参数。 无法解决它。 - Sparsh Dutta
我正在尝试以这种方式实现它:private GoogleMap map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.maps)) .getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap map) { map.addMarker(new MarkerOptions() .position(new LatLng(0, 0)) .title("Marker")); } });我得到的错误是:Error:(52, 25) error: incompatible types: void cannot be converted to GoogleMap - Sparsh Dutta
谢谢!这个修复对我很有用。得爱快速修复。 - flareartist

0

按照以下步骤,可以解决我的问题。

在 build.gradle(module app) 文件中:

  1. 应用插件:

     apply plugin: 'com.jakewharton.butterknife'
    
  2. 在依赖项部分添加以下行:

     annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
     implementation 'com.jakewharton:butterknife:8.7.0'
    
在 build.gradle(Project:projectName) 文件中,像这样在 dependencies 中添加 classPath:
    classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'

它将解决这个问题。 如果不行的话,就添加maven:

 maven {
 url 'https://maven.google.com'
 }

0
Adding these two line in app/build.gradle 

dependencies {
  compile 'com.jakewharton:butterknife:8.8.1'
  annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}


It worked for me 

@PareshMangukiya,因为它重复了ישו אוהב אותך的现有2.5年答案meyasir的答案的解决方案。 - Mark Rotteveel

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接