Reputation: 133
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"
package="com.example.shaikhaalothman.playsongservice">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".PlaySongService"
android:enabled="true"
android:exported="true"></service>
</application>
</manifest>
and it gives me an error at this line:
android:name=".PlaySongService"
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?
Upvotes: 12
Views: 48016
Reputation: 3
For me it resolved for me by changing: @mipmap/logo1.jpeg to @mipmap/ic_launcher back again.
Upvotes: 0
Reputation: 1
you should check your package within the java activity. clear the package name and rewrite it according to your project. example- package com.app.gmail
Upvotes: 0
Reputation: 2599
The only thing that worked for me was File > Invalidate Caches / Restart
.
Upvotes: 13
Reputation: 3104
Put PlaySongService.java
and MainActivity.java
in the same package, named com.example.shaikhaalothman.playsongservice
. It will resolve automatically.
Upvotes: 8
Reputation: 159
Rename package from AndroidManifest.xml with Shift+F6 from "com.example.loa" to "com.example1.loa" ... Then go reverse rename package from "com.example1.loa" to "com.example.loa" ... That will solve the problem , because Android Studio will rebuild project with new name , then will rebuild project with old name ...
Upvotes: 0
Reputation: 17
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
Upvotes: 0
Reputation: 61
Though this is an older thread, I thought I'd include my steps to resolve this issue should it help anyone:
applicationId "com.domain.packagename"
in the module build.gradle file has the correct domain name entered.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.
Upvotes: 6
Reputation: 13115
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.
Upvotes: 0
Reputation: 1
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') }
Upvotes: 0