我正在尝试将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
并 …
这是我在gradle
为我的android项目添加新依赖项时得到的以下错误.而且这个错误不是项目特定的.如果我在添加任何第三方插件时在任何其他Android项目错误中添加插件,我会得到相同的错误
我还发布了我的项目应用级gradle
模块截图
我甚Annotation Processor
至在设置中启用了.仍然没有解决方案 请帮忙.
"A long time ago in a galaxy far, far away...."
Run Code Online (Sandbox Code Playgroud)
好吧,长话短说 - 我决定尝试Android Studio 3.0 Preview (Canary 2)
一下,我不能Dagger 2
使用annotationProcessor
而不是使用它android-apt
.
我得到的错误消息是一个简单的消化:
Error:(59, 24) error: cannot find symbol variable DaggerAppComponent
Run Code Online (Sandbox Code Playgroud)
我已经阅读了文档(我想没有什么花哨的):https://developer.android.com/studio/preview/features/new-android-plugin-migration.html#annotationProcessor_config
并将build.gradle
文件更改为:
implementation "com.google.dagger:dagger:$rootProject.ext.daggerVersion"
annotationProcessor "com.google.dagger:dagger-android-processor:$rootProject.ext.daggerVersion"
Run Code Online (Sandbox Code Playgroud)
哪里 daggerVersion = '2.11'
此外,我确保在Android Studio中检查了相应的选项(默认情况下未选中):
File -> Other Settings -> Default Settings ->
Build, Execution, Deployment -> Compiler -> Annotation Processors ->
Enable annotation processors -> IS CHECKED
Run Code Online (Sandbox Code Playgroud)
不幸的是,它没有帮助.
摇篮:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0-milestone-1-all.zip
Run Code Online (Sandbox Code Playgroud)
Gradle的Android插件: …
android dagger-2 android-apt annotation-processor android-studio-3.0
我编写了一个简单的 Annotation Processor(只是为了好玩),它将生成一些我在之前的项目中编写的样板代码。它实际上通过收集 Activity 类的注释来生成如下模块
@Module
abstract class ActivityInjectorModule {
@ContributesAndroidInjector
abstract fun providesMain2Activity(): Main2Activity
@ContributesAndroidInjector
abstract fun providesMainActivity(): MainActivity
}
Run Code Online (Sandbox Code Playgroud)
但是,当我使用 dagger 运行它时,dagger 似乎无法找到我的 annotation processor 生成的类。虽然生成了类并存在于生成的目录中,但我可以在我的源代码中使用它,但是在编译时,dagger 会产生以下异常。有什么专家建议吗?
error: cannot find symbol
@dagger.Component(modules = {dagger.android.AndroidInjectionModule.class, com.mallaudin.daggietest.di.AppModule.class, ActivityInjectorModule.class})
^
symbol: class ActivityInjectorModule
Run Code Online (Sandbox Code Playgroud)
这是主要的应用程序组件。
@Singleton
@Component(
modules = [
AndroidInjectionModule::class,
AppModule::class,
ActivityInjectorModule::class
]
)
interface AppComponent : AndroidInjector<App> {
@Component.Builder
interface Builder {
fun addContext(@BindsInstance ctx: Context): Builder
fun build(): AppComponent
}
}
Run Code Online (Sandbox Code Playgroud)
ActivityInjectorModule类由注解处理器生成,存在于生成目录中。
应用类
class App : …
Run Code Online (Sandbox Code Playgroud) java android annotation-processing dagger-2 annotation-processor
对于检测测试,我有一个TestApplication
创建一个TestComponent
,但不再生成文件(Error:/xxx/TestApplication.java:16: The import.xxx.DaggerTestApplicationComponent cannot be resolved
).我无法确定根本原因.我尝试了不同的Android Studio(2.2,2.1.2),不同的gradle插件(2.2.0-alpha6,5,4)和不同版本的dagger(2.2到2.6).
我应该用androidTestAnnotationProcessor
吗?(以前不是这种情况)
编辑:使用dagger 2.6,需要添加 classpath 'com.google.guava:guava:19.0'
更新:a出现问题Module
,因此Component
无法创建.但是,使用插孔(即使有调试选项),我也看不到问题.现在,恢复到java 7,gradle插件2.1.2.这样,无需指定哪个番石榴版本,以及所有最新的库都可以使用(dagger 2.6,butterknife 8.2.1,apt 1.8)
android android-gradle-plugin android-instrumentation dagger-2 annotation-processor
我正在使用AndroidAnnotaion
,但由于Android Studio 2.3和Gradle 2.3.0,他们说android-apt
已经过时了.而且annotationProcessor
是一个新的.所以,我想知道我怎么能annotationProcessor
像apt
以前一样配置.
如果我误解了什么,请帮忙.
所以,之前......
apply plugin: 'android-apt'
dependencies {
def AAVersion = '4.2.0'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
apt {
arguments {
library 'true'
}
}
Run Code Online (Sandbox Code Playgroud)
现在...
dependencies {
def AAVersion = '4.2.0'
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
Run Code Online (Sandbox Code Playgroud) android android-annotations android-gradle-plugin android-apt annotation-processor
所以,我已经阅读了本网站上有关此问题的所有问题.我还与一位有类似问题的开发人员聊天,他能够解决这个问题.
我没有在我的gradle脚本中编写apt或annotationProcessor.
我的代码中没有任何地方写过android-apt这个词.我甚至继续检查了所有的库.这包含在我的项目中.
这是一个非常大的问题,需要解决.
我在下面附加修改后的build.gradle,请建议:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
android {
dexOptions {
jumboMode = true
}
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.legalimpurity.indiancourts"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode rootProject.ext.versionCode
versionName rootProject.ext.versionName
multiDexEnabled true
vectorDrawables.useSupportLibrary = true;
}
buildTypes {
release {
// minifyEnabled true
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
signingConfigs {
}
dataBinding {
enabled = true
}
}
//For Facebook i guess
repositories {
mavenCentral()
maven {
url "https://jitpack.io"
}
maven { …
Run Code Online (Sandbox Code Playgroud) 我正在构建一个注释处理器,我最近使用kotlin-kapt插件从使用默认的annotationProcessor类型转换为kapt.
我正在使用该命令调试我的处理器
./gradlew --no-daemon -Dorg.gradle.debug=true :app:clean :app:compileDebugJavaWithJavac
Run Code Online (Sandbox Code Playgroud)
(完整说明:https://stackoverflow.com/a/42488641/502463)
然后运行远程调试配置.当我使用annotationProcessor时,我可以点击断点,并进行调试.使用kapt,我的处理器运行,但我无法调试它.没有触发断点.
我的kotlin版本是1.1.2-3
remote-debugging annotation-processing kotlin kapt annotation-processor
我在现有代码中使用了数据绑定,现在我正在迁移到Room以进行持久化.我已经按照Florina博客中提到的步骤进行了访问
当我删除房间依赖时,我的代码构建正常,没有java代码错误或BR相关错误
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
Run Code Online (Sandbox Code Playgroud)
和它的运行,但给出运行时异常,说database_Impl不存在.因为它无法生成该文件.
但是在我把Annotation处理器放回去后,它给了我
Error:(29, 37) error: cannot find symbol class BR
Run Code Online (Sandbox Code Playgroud)
我使用的gradle插件是 com.android.tools.build:gradle:3.0.1
他们似乎都没有合作
迄今采取的步骤:
有没有人使用Room和Data绑定在一起?
android 2-way-object-databinding android-databinding annotation-processor android-room
android ×8
android-apt ×3
dagger-2 ×3
gradle ×2
android-room ×1
java ×1
kapt ×1
kotlin ×1
maven ×1