简体   繁体   English

导入模块中的任何内容都会导致Android Studio中出现“无法解析符号”错误

[英]Importing Anything in a Module Leads to 'Cannot resolve symbol' Error in Android Studio

I simply wanted to create a Jar archive (.jar file) out of my classes using Android Studio. 我只是想使用Android Studio在类之外创建一个Jar存档(.jar文件)。 To do so, I created a module using File > New > New Module > Java Library . 为此,我使用File> New> New Module> Java Library创建了一个模块。 Then I wrote two classes (LocationAndroidPlugin, MyLocationService) in the module: 然后,我在模块中编写了两个类(LocationAndroidPlugin,MyLocationService):

在此处输入图片说明

But Android Studio complains that it cannot resolve the import statements in the classes: 但是Android Studio抱怨说它无法解析类中的import语句:

在此处输入图片说明

I tried File > Invalidate Cache in vain. 我徒劳地尝试了File> Invalidate Cache

My Android Studio version is: Android Studio 2.3.1 Build #AI-162.3871768, built on April 1, 2017 JRE: 1.8.0_112-release-b06 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains sro 我的Android Studio版本是:Android Studio 2.3.1 Build#AI-162.3871768,建立于2017年4月1日JRE:1.8.0_112-release-b06 amd64 JVM:JetBrains sro的OpenJDK 64位服务器VM

You should not use Java Library option if you want to use serviceConnection, activity, or intent because it does not have Android classes. 如果要使用serviceConnection,activity或intent,则不应使用Java Library选项,因为它没有Android类。 Instead, you must create the new module as an Android Library from File > New > New Module > Android Library . 相反,你必须创建新的模块为Android库文件>新建>新建模块>的Android库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM