Tag: kapt

Android上的Dagger 2,缺少错误信息

我在我的Android项目中使用Dagger 2,并且在调试时遇到了麻烦。 我知道编译失败,因为我的匕首2设置(之前有过)的错误,但它几乎是不可能的,因为我没有得到一个正确的错误信息告诉我问题在哪里。 我所得到的是显示注释处理失败的消息。 沿着: Error:Execution failed for task ‘:app:compileDebugJavaWithJavac’. > Compilation failed; see the compiler error output for details. Error:(14, 28) error: cannot find symbol class BR Error:(17, 40) error: package com.some.package.databinding does not exist Error:(17, 51) error: cannot find symbol class DaggerSomeComponent … 也许这与我正在使用数据绑定的事实有某种关系! 我使用的是Dagger 2.5,Gradle插件2.1.2和android-apt 1.8。 谢谢你的帮助!

使用kapt和gradle时,无法调试注释处理器

我正在构建一个注释处理器,最近我使用kotlin-kapt插件将默认的annotationProcessortypes转换为kapt。 我正在使用该命令调试我的处理器 ./gradlew –no-daemon -Dorg.gradle.debug=true :app:clean :app:compileDebugJavaWithJavac (完整的说明在这里: https : //stackoverflow.com/a/42488641/502463 ) 然后运行远程调试配置。 当我使用annotationProcessor时,我可以打断点,并且很好地调试。 与kapt,我的处理器运行,但我无法调试它。 没有断点被触发。 我的kotlin版本是1.1.2-3

在Android Studio 3.0中,Kapt不适用于AutoValue

Gradle依赖关系: compile ‘com.google.dagger:dagger:2.9’ annotationProcessor ‘com.google.dagger:dagger-compiler:2.9’ kapt ‘com.google.dagger:dagger-compiler:2.9’ provided “com.google.auto.value:auto-value:1.4.1” annotationProcessor “com.google.auto.value:auto-value:1.4.1” 得到这个堆栈跟踪: :presentation:kaptDevDebugKotlin e: @AutoValue public abstract class Categories implements CategoriesModel{ e: ^ e: symbol: class CategoriesModel e: path/Categories.java:13: error: cannot find symbol w: warning: The following options were not recognized by any processor: ‘[kapt.kotlin.generated]’ w: e: org.jetbrains.kotlin.kapt3.diagnostic.KaptError: Error while annotation processing at org.jetbrains.kotlin.kapt3.AnnotationProcessingKt.doAnnotationProcessing(annotationProcessing.kt:90) at […]

如何设置maven kapt的参数

如何使用kotlin-maven-plugin在maven中设置? 这是gradle脚本: kapt{ arguments { arg(“codegen.output”, project.file(‘src/main/generated’).path) arg(“kapt.kotlin.generated”, project.file(‘src/main/generated’).path) } } 谢谢!

kapt是否支持maapt?

是否有可能在基于maven的项目中运行kapt(kotlin注释处理)? 如果是的话,我如何将kapt集成到maven构建系统中?

如何在Enum常量中实现抽象函数

我想要实现的是一个简单的模式,我正在使用Java,并应根据文档在Kotlin中可行。 我只是想用一些实现相同抽象函数的常量定义来声明一个枚举类。 我的问题是,我无法设法让我的代码编译。 我总是得到相同的错误: modifier abstract not allowed here 这里是代码: enum class Program { HOME { override fun readableName(context: Context): String { return context.getString(R.string.program_home) } }, WEEKEND { override fun readableName(context: Context): String { return context.getString(R.string.program_weekend) } }, SHOPPING { override fun readableName(context: Context): String { return context.getString(R.string.program_shopping) } }; abstract fun readableName(context: Context): String […]

kapt构建失败与匕首Android处理器

我试图用Kotlin注解处理工具 (kapt)在我的项目中包含Dagger Android处理器( 在此记录)。 我已经在我的build.gradle文件中包含了适当的依赖关系: apply plugin: ‘com.android.application’ apply plugin: ‘kotlin-android’ apply plugin: ‘kotlin-kapt’ android { compileSdkVersion 25 buildToolsVersion “25.0.2” defaultConfig { applicationId “com.example.app” minSdkVersion 16 targetSdkVersion 25 versionCode 1 versionName “1.0” testInstrumentationRunner “android.support.test.runner.AndroidJUnitRunner” } sourceSets { main.java.srcDirs += ‘src/main/kotlin’ } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.pro’ } } } dependencies { […]

使用Kapt和Dagger2进行注释处理时出错

我花了一些时间与我的错误,但没有任何积极的结果,所以我可能有人可以帮助。 我的项目中有3个模块:应用程序(android),数据,域 – 都是纯kotlin。 所有DI都在应用程序模块中。 ApplicationComponent&ApplicationModule: @Singleton @Component(modules = arrayOf(ApplicationModule::class, NavigatorModule::class, RepositoryModule::class, FirebaseModule::class, SchedulerModule::class, UseCaseModule::class)) interface ApplicationComponent { fun injectApplication(application: Application) fun loginSubComponent() : LoginSubComponent } @Module class ApplicationModule(private val application: Application) { @Provides @Singleton fun provideApplication() = application } @Module class UseCaseModule { @Provides @Singleton fun provideLoginAccountUseCase(scheduler: ComposeScheduler, repository: AccountRepository) = LoginAccountUseCase(scheduler, repository) @Provides […]

Android studio 3稳定版“房间1(RC)”的“app:kaptDebugKotlin”错误

编译我写在kotlin中的项目时,我仍然遇到这个错误: 错误:执行任务’:app:kaptDebugKotlin’失败。 内部编译器错误。 查看日志了解更多详情 有没有人有这个bug的解决方法或解决方案? 我已经看到了几乎所有围绕这个问题的答案,但是在这个级别上非常有用。 我应该补充说,项目工作正常,没有任何改变从gradle突然间,我得到了编译错误

Android Room Persistences库和Kotlin

我正在尝试使用Kotlin和Room Persistance Library编写一个简单的应用程序。 我遵循Android Persistance codelab中的教程 。 这是我在Kotlin的AppDatabase类: @Database(entities = arrayOf(User::class), version = 1) abstract class AppDatabase : RoomDatabase() { abstract fun userModel(): UserDao companion object { private var INSTANCE: AppDatabase? = null @JvmStatic fun getInMemoryDatabase(context: Context): AppDatabase { if (INSTANCE == null) { INSTANCE = Room.inMemoryDatabaseBuilder(context.applicationContext, AppDatabase::class.java).allowMainThreadQueries().build() } return INSTANCE!! } @JvmStatic fun destroyInstance() […]