gpt4 book ai didi

java - Android Studio (0.8.2) + Android Annotations (3.0.1) cannot symbol class MyClass

转载 作者:行者123 更新时间:2023-11-29 08:46:25 30 4
gpt4 key购买 nike

几天来我一直遇到注释问题...

Error:(13, 26) cannot find symbol class LoginActivityAnnotations_

但是注释类存在并且我的 MainActivity 中的类导入效果很好 http://imagizer.imageshack.us/v2/150x100q90/911/x8RzRM.png

注释类在此目录中正确生成: http://imagizer.imageshack.us/v2/150x100q90/538/bEplNx.png

这是我的 build.grandle 文件

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:+'
}
}
apply plugin: 'android'
apply plugin: 'android-apt'

repositories {
mavenCentral()
mavenLocal()
}
apt {
arguments {
resourcePackageName "com.ar.sdocs"
androidManifestFile variant.processResources.manifestFile
}
}
dependencies {
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'

apt "org.androidannotations:androidannotations:+"
compile 'org.androidannotations:androidannotations-api:+'

compile 'com.nhaarman.listviewanimations:library:2.6.0'
compile files('libs/commons-lang3-3.3.1.jar')
compile 'com.google.android.gms:play-services:4.3.+'
compile files('libs/joda-time-2.3.jar')
compile files('libs/bcprov-ext-jdk15on-150.jar')
compile files('libs/bugsense-3.6.1.jar')
compile 'org.apache.httpcomponents:httpcore:4.3.2'
compile 'org.apache.httpcomponents:httpmime:4.3.4'
compile 'com.google.code.gson:gson:2.2.4'
compile files('libs/json-simple-1.1.1.jar')
apt "org.androidannotations:androidannotations:+"
compile 'org.androidannotations:androidannotations-api:+'
}

android {
compileSdkVersion 19
buildToolsVersion '19.1.0'

defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName '0.1'
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
}
}

android.applicationVariants.each { variant ->
aptOutput = file("${project.buildDir}/generated/source/apt/${variant.dirName}")
println "****************************"
println "variant: ${variant.name}"
println "manifest: ${variant.processResources.manifestFile}"
println "aptOutput: ${aptOutput}"
println "****************************"

variant.javaCompile.doFirst {
println "*** compile doFirst ${variant.name}"
aptOutput.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.getAsPath(),
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', aptOutput
]
}

variant.addJavaSourceFoldersToModel(aptOutput)
}

但是每次我运行构建时,我都会遇到我之前提到的错误。几天前我正在尝试不同的配置,但找不到有效的配置

那是完整的错误(我只导入了注解类)

Error:(14, 26) cannot find symbol class LoginActivityAnnotations_
Note: Resolve log file to /Users/CARRY/AndroidStudioProjects/sdocs/SDocs/build/generated/source/apt/androidannotations.log
Note: Initialize AndroidAnnotations 3.0.1 with options {resourcePackageName=com.ar.sdocs, androidManifestFile=/Users/CARRY/AndroidStudioProjects/sdocs/SDocs/build/intermediates/manifests/debug/AndroidManifest.xml}
Note: Start processing for 5 annotations on 145 elements
Note: AndroidManifest.xml file found with specified path: /Users/CARRY/AndroidStudioProjects/sdocs/SDocs/build/intermediates/manifests/debug/AndroidManifest.xml
Note: AndroidManifest.xml found: AndroidManifest [applicationPackage=com.ar.sdocs, componentQualifiedNames=[com.ar.sdocs.main.MainActivity, com.ar.sdocs.login.LoginActivity, com.ar.sdocs.dashboard.DashboardActivity, com.ar.sdocs.login.registro.RegistroActivity, com.ar.sdocs.dashboard.settings.editar.SettingsUserEditActivity, com.ar.sdocs.dashboard.upload.UploadActivity, com.ar.sdocs.dashboard.materias.main.MateriaActivity, com.ar.sdocs.util.media.FilePickerActivity, com.ar.sdocs.gcm.GcmIntentService, com.ar.sdocs.gcm.GcmBroadcastReceiver], permissionQualifiedNames=[android.permission.USE_CREDENTIALS, android.permission.GET_ACCOUNTS, android.permission.READ_PROFILE, android.permission.READ_CONTACTS, android.permission.INTERNET, android.permission.WAKE_LOCK, com.google.android.c2dm.permission.RECEIVE, android.permission.CAMERA, android.permission.READ_EXTERNAL_STORAGE, com.example.gcm.permission.C2D_MESSAGE], applicationClassName=null, libraryProject=false, debugabble=false, minSdkVersion=14, maxSdkVersion=-1, targetSdkVersion=19]
Note: Found project R class: com.ar.sdocs.R
Note: Found Android class: android.R
Note: Validating elements
Note: Validating with EActivityHandler: [com.ar.sdocs.login.LoginActivityAnnotations]
/Users/CARRY/AndroidStudioProjects/sdocs/SDocs/src/main/java/com/ar/sdocs/login/LoginActivityAnnotations.java
Warning:(45, 1) The component LoginActivityAnnotations_ is not registered in the AndroidManifest.xml file.
Note: Validating with ViewByIdHandler: [emailEditText, passwordEditText]
Note: Validating with ClickHandler: [loginButtonClicked(), registerButtonClicked()]
Note: Validating with TouchHandler: [loginRelativeLayoutTouched(android.view.View,android.view.MotionEvent)]
Note: Validating with AfterViewsHandler: [verificarLogin()]
Note: Processing root elements
Note: Processing root elements EActivityHandler: [com.ar.sdocs.login.LoginActivityAnnotations]
Note: Processing enclosed elements
Note: Number of files generated by AndroidAnnotations: 1
Note: Writting following API classes in project: []
Note: Generating class: com.ar.sdocs.login.LoginActivityAnnotations_
Note: Time measurements: [Whole Processing = 148 ms], [Process Annotations = 32 ms], [Generate Sources = 31 ms], [Find R Classes = 24 ms], [Extract Annotations = 23 ms], [Validate Annotations = 16 ms], [Extract Manifest = 11 ms],
Note: Finish processing
Note: Start processing for 0 annotations on 1 elements
Note: Time measurements: [Whole Processing = 3 ms],
Note: Finish processing
Note: Start processing for 0 annotations on 0 elements
Note: Time measurements: [Whole Processing = 1 ms],
Note: Finish processing
Warning:Unclosed files for the types '[dummy1407025286017]'; these types will not undergo annotation processing
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Information:BUILD SUCCESSFUL
Information:Total time: 21.886 secs
Information:1 error
Information:4 warnings
Information:See complete output in console

最佳答案

我可能是因为您没有在使用它的地方包含 LoginActivityAnnotations_ 文件 - 因为 Android Studio 无法帮助您。我有那个问题。

您需要包含 LoginActivityAnnotations 文件所在的包。如果您使用此包含,获取不带下划线的文件:

com.example.LoginActivityAnnotations

然后使用这个:

com.example.* //To load LoginActivityAnnotations_

(包含将是灰色的,你仍然会留下红色的字,但它会编译)

关于java - Android Studio (0.8.2) + Android Annotations (3.0.1) cannot symbol class MyClass,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25100610/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com