Kamran Bigdely
Kamran Bigdely

Reputation: 8456

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. To do so, I created a module using File > New > New Module > Java Library. Then I wrote two classes (LocationAndroidPlugin, MyLocationService) in the module:

enter image description here

But Android Studio complains that it cannot resolve the import statements in the classes:

enter image description here

I tried File > Invalidate Cache in vain.

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 s.r.o

Upvotes: 0

Views: 1597

Answers (1)

Umut Aksun
Umut Aksun

Reputation: 179

You should not use Java Library option if you want to use serviceConnection, activity, or intent because it does not have Android classes. Instead, you must create the new module as an Android Library from File > New > New Module > Android Library.

Upvotes: 2

Related Questions