android - 注释处理器不工作 - 没有创建文件

标签 android android-studio build.gradle android-build annotation-processor

我现在已经在寻找我自己的注释处理器无法在我的一个项目中工作的原因。设置如下所示:

  • Android Studio 2.3.3
  • gradle 构建工具 2.3.3
  • 在 android studio 中启用了注释处理器

我尝试了常见的解决方案:

  • 从 Android Studio 最近删除我的项目
  • 使缓存失效并重启android studio
  • 将我的项目再次导入android studio(确保之前启用了注释处理)

没有任何帮助。我在另一个项目中进行了注释处理,并将其与这个项目进行了比较。唯一的区别是我在另一个项目中使用了 kotlin。所以我刚刚在我的新项目中添加了以下内容:

Kotlin 和 apply plugin: 'kotlin-android' 突然注解处理开始工作了。为什么?我还没有发现任何关于这个的东西,但在我的例子中,注释处理不再工作(在旧的 android 版本中它肯定会工作,但不确定它什么时候坏了)而不应用 kotlin 插件.. .

据我所知,我不必应用注释处理器插件,对吗?我还缺少其他东西吗?

示例build.gradle:

apply plugin: 'com.android.library'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'kotlin-android'

android {

    if (project.hasProperty('setup.compileSdk'))
    {
        compileSdkVersion setup.compileSdk
        buildToolsVersion setup.buildTools
        defaultConfig {
            minSdkVersion setup.minSdk
            targetSdkVersion setup.targetSdk
        }
    }
    else
    {
        compileSdkVersion 26
        buildToolsVersion "26.0.1"
        defaultConfig {
            minSdkVersion 21
            targetSdkVersion 26
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dataBinding.enabled = true

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    retrolambda {
        jvmArgs '-noverify'
    }
}

dependencies {

    // dependencies...

    compile project(':bundleargs-annotation')
    annotationProcessor project(':bundleargs-processor')
}

最佳答案

  1. Android Studio - 文件 - 关闭项目
  2. 配置 - 设置 - 构建、执行、部署 - 编译器 - 注释处理器 - 启用注释处理。
  3. 打开项目 - 构建 - 重建项目。

如果没有帮助 - 重新创建项目。

关于android - 注释处理器不工作 - 没有创建文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45826037/

相关文章:

java - 使用 Fragment 类中的数据库填充 android ListView 时发生意外错误

android - 数组整数逻辑

android - Flutter HTTP 服务器 - 在另一个应用程序中提供 Flutter Web 服务

gradle - Gradle 中具有不断变化的依赖集的多个构建任务

安卓工作室 0.4.2 : Gradle project sync failed error

android - 如何从 Activity 启动 Fragment?

android-studio - AS-翻译编辑器-如何一次删除所有语言的字符串?

android - 在没有 Android Studio 的情况下构建项目

android - 'GoogleSignIn 被标记为内部,不应从应用程序访问'用于新的 Google Play 服务实现

android - ManifestPlaceholder 将 NumericString 转换为实际数字?