"Unresolved class" error in in AndroidManifest.xml

I get an error in my manifest xml file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

        <activity android:name=".MainActivity">
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />



and it gives me an error at this line:


and the error reads:

Unresolved class 'PlaySongService'

Validates resource reference inside Android XML files.

I haven't found anything that helps to resolve my error here on Stackoverflow, and elsewhere. Anyone that knows what I'm doing wrong?

PUT PlaySongService.java and MainActivity.java in Same package named com.example.shaikhaalothman.playsongservice, it will resolved automatically.

Though this is an older thread, I thought I'd include my steps to resolve this issue should it help anyone:

  1. Verify that the line applicationId "com.domain.packagename" in the module build.gradle file has the correct domain name entered.
  2. Make sure that that this domain name matches your package name under your java folder. An easy way to update this is to go to the settings gear in the top right corner of the Project pane and uncheck "Hide empty middle packages" if it isn't, then right-click refactor-rename the folder with your domain name.
  3. Finally, ensure this domain name is also correctly entered in the package tag at the top of your manifest file.

My issue was that the directory under java had the incorrect package name, so I had to change it to match the gradle and manifest files.

You have to include a path in your "build.gradle" file. I had the same problem as shown in the picture in the link: Unresolved class

Open the "build.gradle" file in your editor and add a path line to the dependencies, as shown below: dependencies { implementation project(path: ':theClassPathGoesHere') }

In my case, none of the solutions above worked because I had already checked that the package names, etc. were correct.

So I took the approach of comparing my activities to a new activity generated by Android Studio. I'm on Android Studio 3.1.3. I chose File > New Activity > Basic Activity and the first thing I discovered was the package name it defaulted was red.

I checked, and sure enough my applicationId in my module-level build.gradle file was not equal to the package name of my existing activities. I corrected that, but it didn't make the error go away.

So, I completed the process of generating the Basic Activity to ensure that I didn't get the Unresolved class error. As I expected, the AndroidManifest.xml entry generated by Android Studio did not have the error. Meanwhile my existing activities continued to have an error. So I then compared my existing activities to the generated one. I discovered that my activities extended the Activity class where as the generated one extended AppCompatActivity. So I tried changing from Activity to AppCompatActivity. This generated a bunch of errors I didn't want to deal with, so I changed them back from AppCompatActivity to Activity. And suddenly Android Studio didn't warn me about any Unresolved class errors anymore.

I'm not sure what's really going on. I thought maybe something got corrupted in my .idea directory, but wiping that out and reimporting didn't solve the problem.

In summary, what seems to eliminate the Unresolved class error is: change your activity's java file from extending Activity to extend AppCompatActivity and then change it back to Activity. That resolved the errors for me.

in the android manifest file in android:name="____" my package name was wrong so copying my package name from the top of the manifest file stated in package:"____" resolved my error

  • is there any .PlaySongService class in your project
  • Try to clean your project. (assuming .PlaySongService class is in your project as Nilesh mentioned)
  • What's the package of the PlaySongService? It should be com.example.shaikhaalothman.playsongservice, otherwise it won't find the class.
  • Please show your PlaySongService.java
  • Is PlaySongService available in com.example.shaikhaalothman.playsongservice package?