我正试图在Android Studio项目中创建自己的注释处理器。
我已经在Android Studio中为此创建了另一个模块。
我能够编译这个项目。我不能只使用自动完成和其他东西。在这种情况下,IDE将所有引用视为未解析的引用错误
我如何解决这个问题?
什么是重要的
当我创建新的库模块“autoadapter进程”时,默认情况下,Android Studio在构建中使用此实现创建了它。此模块的渐变:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
为了能够编译项目,我将其替换为:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
下面是我的项目结构:
以下是我对autoadapter处理器模块的Gradle配置:
apply plugin: 'java-library'
apply plugin: 'kotlin'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project(':autoadapter-annotations')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
这https://stackoverflow.com/a/61180376/104891这个问题和我的不一样,因为它是智能化的。它不是特定于Android Studio的。
看起来,Android Studio缓存了为新的Android Studio版本导入的一些以前的设置。我做了很长一段时间,可能是从3.1版开始更新-
因此旧的JDK版本似乎被缓存在JDK中。桌子xml文件
你可以在你的Android Studio选项文件夹中找到这个文件(在我的情况下,它是用户/库/首选项/Android Studio4.0/选项)
你可以删除它,让它再次创建正确的版本(这对我有效,是我问题的解决方案:https://stackoverflow.com/a/38067170/5434346
或者你可以尝试修改它(我没有尝试过):https://stackoverflow.com/a/41531367/5434346
奇怪的是,它没有包含任何JDK 1.7参考:
<application>
<component name="ProjectJdkTable">
<jdk version="2">
<name value="1.8" />
<type value="JavaSDK" />
<version value="java version "1.8.0_152-release"" />
<homePath value="$APPLICATION_HOME_DIR$/jre/jdk/Contents/Home" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/lib/jdkAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/charsets.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/cldrdata.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/dnsns.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/jaccess.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/localedata.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/nashorn.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/sunec.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/ext/zipfs.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/jce.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/jsse.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/management-agent.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/resources.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/jre/lib/rt.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/lib/dt.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/lib/jconsole.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/lib/sa-jdi.jar!/" type="simple" />
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/jre/jdk/Contents/Home/lib/tools.jar!/" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root url="http://docs.oracle.com/javase/8/docs/api/" type="simple" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional />
</jdk>
<jdk version="2">
<name value="Android API 27 Platform" />
<type value="Android SDK" />
<version value="java version "1.8.0_152-release"" />
<homePath value="$USER_HOME$/Library/Android/sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/plugins/android/lib/androidAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/Library/Android/sdk/platforms/android-27/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/Library/Android/sdk/platforms/android-27/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root url="http://developer.android.com/reference/" type="simple" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-27" />
</jdk>
<jdk version="2">
<name value="Android API 25 Platform" />
<type value="Android SDK" />
<version value="java version "1.8.0_152-release"" />
<homePath value="$USER_HOME$/Library/Android/sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/plugins/android/lib/androidAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/Library/Android/sdk/platforms/android-25/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/Library/Android/sdk/platforms/android-25/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root url="http://developer.android.com/reference/" type="simple" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-25" />
</jdk>
<jdk version="2">
<name value="Android API 26 Platform" />
<type value="Android SDK" />
<version value="java version "1.8.0_152-release"" />
<homePath value="$USER_HOME$/Library/Android/sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$APPLICATION_HOME_DIR$/plugins/android/lib/androidAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/Library/Android/sdk/platforms/android-26/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/Library/Android/sdk/platforms/android-26/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite" />
</javadocPath>
<sourcePath>
<root type="composite">
<root url="file://$USER_HOME$/Library/Android/sdk/sources/android-26" type="simple" />
</root>
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-26" />
</jdk>
<jdk version="2">
<name value="Android API 23 Platform" />
<type value="Android SDK" />
<version value="java version "1.8.0_152-release"" />
<homePath value="$USER_HOME$/Library/Android/sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar:///private/var/folders/b2/cyvk3_yx2g79yctwzx_l7lx80000gn/T/AppTranslocation/2A3A91C1-D3F4-4B90-9B20-E2C1047BDD8F/d/Android Studio 3.5.app/Contents/plugins/android/lib/androidAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/Library/Android/sdk/platforms/android-23/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/Library/Android/sdk/platforms/android-23/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root url="http://developer.android.com/reference/" type="simple" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-23" />
</jdk>
<jdk version="2">
<name value="Android API 28 Platform" />
<type value="Android SDK" />
<version value="java version "1.8.0_152-release"" />
<homePath value="$USER_HOME$/Library/Android/sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$USER_HOME$/Library/Android/sdk/platforms/android-28/data/annotations.zip!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/Library/Android/sdk/platforms/android-28/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/Library/Android/sdk/platforms/android-28/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root url="http://developer.android.com/reference/" type="simple" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-28" />
</jdk>
<jdk version="2">
<name value="Kotlin SDK" />
<type value="KotlinSDK" />
<version value="1.3.30" />
<homePath value="$USER_HOME$/Library/Application Support/AndroidStudio3.6/Kotlin/kotlinc" />
<roots>
<annotationsPath>
<root type="composite" />
</annotationsPath>
<classPath>
<root type="composite" />
</classPath>
<javadocPath>
<root type="composite" />
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional />
</jdk>
<jdk version="2">
<name value="Android API 29 Platform" />
<type value="Android SDK" />
<version value="java version "1.8.0_152-release"" />
<homePath value="$USER_HOME$/Library/Android/sdk" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$APPLICATION_HOME_DIR$/plugins/android/lib/androidAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar://$USER_HOME$/Library/Android/sdk/platforms/android-29/android.jar!/" type="simple" />
<root url="file://$USER_HOME$/Library/Android/sdk/platforms/android-29/data/res" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite">
<root url="http://developer.android.com/reference/" type="simple" />
</root>
</javadocPath>
<sourcePath>
<root type="composite" />
</sourcePath>
</roots>
<additional jdk="1.8" sdk="android-29" />
</jdk>
<jdk version="2">
<name value="1.8.0_161" />
<type value="JavaSDK" />
<version value="java version "1.8.0_161"" />
<homePath value="/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home" />
<roots>
<annotationsPath>
<root type="composite">
<root url="jar://$APPLICATION_HOME_DIR$/lib/jdkAnnotations.jar!/" type="simple" />
</root>
</annotationsPath>
<classPath>
<root type="composite">
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/charsets.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/deploy.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/cldrdata.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/dnsns.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/jaccess.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/jfxrt.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/localedata.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/nashorn.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunec.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunjce_provider.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/sunpkcs11.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/ext/zipfs.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/javaws.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jce.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jfr.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jfxswt.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/jsse.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/management-agent.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/plugin.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/resources.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/jre/lib/rt.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/ant-javafx.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/dt.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/javafx-mx.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/jconsole.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/packager.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/sa-jdi.jar!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/lib/tools.jar!/" type="simple" />
</root>
</classPath>
<javadocPath>
<root type="composite" />
</javadocPath>
<sourcePath>
<root type="composite">
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/src.zip!/" type="simple" />
<root url="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home/javafx-src.zip!/" type="simple" />
</root>
</sourcePath>
</roots>
<additional />
</jdk>
</component>
</application>
无论如何,新文件看起来是这样的,现在我没有遇到我的问题(由于篇幅限制,我无法直接在这里发布内容)https://pastebin.com/EdDKpZAT
然而,当我试图在我的项目Android Studio中创建新模块时,我认为配置和JDK7设置是错误的:
apply plugin: 'java-library'
apply plugin: 'kotlin'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
但是在这个模块里,我可以导入我对javax的引用
升级Android Studio后,一个没有问题的项目开始在编辑器中显示问题。我有很多错误。支持库(support-v4、support-v7)下的任何内容。 在上面的屏幕截图中,任何显示为红色的东西都不会解析并显示为错误。我也使用生命周期组件和房间数据库。他们似乎也有问题。看起来可以找到接口,但类不能。 例如,在我的一个使用的类中, 和Android系统。拱坚持不懈房间类型转换器正确解析,但 和
这一行: 给我错误。 我的项目创建过程非常基本:在Intellij idea中:
导入SBT项目时出错: ... 关于如何解决这个问题的任何建议。导入在另一台机器上运行良好。我看到了.ivy2文件夹中的jar文件。
我已经尝试过使缓存无效。清理构建和重建项目也已完成。但我仍然不断得到未解决的参考:Dispatchers、launch、withContext、delay。。。但CoroutineScope没有标记为未解析引用,即导入kotlinx。协同程序。*未标记为未知,项目正在编译(已运行数月,不是最近的项目)。 Android Studio:4.0.1 设置 建筑格拉德尔 module\u构建。格拉德尔
我使用EclipseMars(M1)作为我的IDE。今天,我使用Apache Thrift 0.9.2(最新稳定版本)为Android项目生成了我的服务的Java代码。这个版本(unlke版本0.9.1)使用来自javax的“生成”注释。注释包,用于添加一些可提取的文档。它在每个生成的类之前添加一行,如下所示: @已生成(value=“节俭编译器自动生成(0.9.2)”,日期=“2014-11-3
我在我的项目中使用了javax.mail库。我的项目使用 - mvn 全新安装构建良好,但是当我尝试调试我的 Intellij IDE 时显示错误,它无法识别 javax.mail 导入。我已经从文件重新启动了我的IDE- intellij IDEA未识别这些未使用的进口。我使用以下depeendency版本:-javax。activation-1.1.1和javax。邮件-1.4。 因为这个项目