注释处理器不起作用-未创建文件 [英] Annotation processor not working - no files are created

查看:63
本文介绍了注释处理器不起作用-未创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在已经搜索了为什么我自己的注释处理器无法在我的一个项目中工作的原因.安装程序如下所示:

I've now searched for reasons why my own annotation processor is not working in ONE of my projects. Setup looks like following:

  • Android Studio 2.3.3
  • 渐变构建工具2.3.3
  • 在Android Studio中启用了
  • 注释处理器
  • Android Studio 2.3.3
  • gradle build tools 2.3.3
  • annotation processor is enabled in android studio

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

I tried the common solutions:

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

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

Nothing helps. I have annotation processing working in another project and compared it with this one. Only difference is that I'm using kotlin in the other project. So I just added following to my new project:

Kotlin和 apply插件:'kotlin-android'并突然进行注释处理.为什么?我还没有发现任何相关信息,但是在我的情况下,如果不应用 kotlin 插件,注释处理将无法正常工作(在较旧的android版本中,它确实可以确定,但不确定何时破裂).

Kotlin and apply plugin: 'kotlin-android' and suddenly annotation processing works. Why? I have not found anything about this yet but in my case, annotation processing does not work anymore (in older android versions it did for sure, not sure when it broke though) without applying the kotlin plugin...

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

As far as I know I don't have to apply the annotation processor plugin, correct? Am I missing something else?

示例 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. 打开项目-构建-重建项目.

如果没有帮助,请重新创建项目.

If it doesn't help - recreate the project.

这篇关于注释处理器不起作用-未创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆