Android Studio 3.1.4 Cannot resolve symbol R - android

I know there are many similar questions, but none of them fix my issue.
Firstly there is an error: Cannot resolve symbol 'R'. Also in the build tab, there is an error: Build: build failed. Over to the side of that, it says Manifest merger failed with multiple errors, see logs.
My program has two activities.
I have tried all the different things people said to try and they didn't work.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dennisranish.wificontroller">
<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=".Controller"
android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Settings"
android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen"
android:screenOrientation="landscape">
<intent-filter>
</intent-filter>
</activity>
</application>
</manifest>
In Merged Manifest tab:
Merging Errors:
Error: Missing one of the key attributes 'action#name,category#name,data#scheme,data#host,data#mimeType,data#port,data#path,data#pathPattern,data#pathPrefix' on element intent-filter at AndroidManifest.xml:25:13-26:29 app main manifest (this file), line 24
Error: Validation failed, exiting app main manifest (this file)
Update:
Your Settings Activity declaration should look like this:
<activity android:name=".Settings"
android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen"
android:screenOrientation="landscape" />
This does fix the AndroidManifest.xml error. However Cannot resolve symbol 'R' is still and issue and in the build tab, there still is an error: Build: build failed. Except now over to the side of that, it now says AAPT2 error: check logs for details.
Also some people said to post the error logs and I was wondering: When I click Help > Show Log in Explorer is it the right log; because there are 12 logs all contain over 1000 lines
Thanks for any help and if any other file is needed please let me know.

Your error message is pretty clear:
Missing one of the key attributes
'action#name,category#name,data#scheme,data#host,data#mimeType,data#port,data#path,data#pathPattern,data#pathPrefix'
on element intent-filter at AndroidManifest.xml
Your Settings Activity has blank intent-filter, removing it will fix the issue.
If intent-filter is added, it must contain action tag and
can/cannot contain category and data tag, Reference Android
intent-filter doc
Your Settings Activity declaration should look like below:
<activity android:name=".Settings"
android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen"
android:screenOrientation="landscape" />
Hope it helps!

Related

"Could not identify launch activity: Default Activity not found" - Android Studio - no answers working

Whenever trying to run the app, getting the error:
"Could not identify launch activity: Default Activity not found".
I have seen a few other threads on the same issue, but the below solutions have not worked for me:
Invalidating gradle cache and re-running
Manually overriding in the edit configuration tab to select the default activity (it then says "The activity 'MainActivity' is not declared in AndroidManifest.xml" even though it is!)
Re-syncing the gradle files
Literally shuffling around the order of the activities in my manifest
Using the long name for my activities, but doesn't make any difference
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mywebname">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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"
android:screenOrientation="portrait"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ListenScreen"
android:parentActivityName=".MainActivity"
android:screenOrientation="portrait">
</activity>
</application>
</manifest>
```
As you can see, I have clearly declared the activities (my app only has 2 so far), and I've put the intents around the ".MainActivity".
This answer worked for me after trying so many other tweaks, just adding the package name solved my problems
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.name">
https://stackoverflow.com/a/72300233/8720836
You can only have to add the package name inside the manifest tag you can find your package name inside app.gradle file and you are good to go

"Session 'app': Error launching activity" all of the sudden?

I am currently running into this issue without even knowing why.
It was working fine yesterday and I just added more code to each activity.
I have already perfomed "Invalidate Cache/Restart" and Restarted my computer.
Note that I did not change anything in the Manifest.xml nor have I added a new activity to the Project.
Here's the AndroidManifest.xml file.
<?xml version="1.0" encoding="utf-8"?>
<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=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".RegisterActivity" />
<activity android:name=".MainScreenActivity" />
<activity android:name=".StatisticsActivity" />
<activity android:name=".UnlockablesActivity"></activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
Any help would be greatly appreciated.
Edit: I have already tried to Rebuild and Clean multiple times. Same error.
The error is a little pop-up on the left corner saying "Error running app: Default Activity not found".
When setting the Default Activity in the settings to Nothing, this error appears in logcat when accessing a different activity.
It is not the full log but you can see that it references Line 25 in LoginActivity (the supposed Default Activity) which leads to its onCreate() function.
I've had exactly the same error a week ago, here's the link to my question. I couldn't find the origin of the error, it is probably a bug with Android Studio (I've had the same thing with all my projects).
I've resolved it by deleting the .AndroidStudio hidden directory in your user folder. Keep in mind, it deletes all the settings you've set before and it will reset Android Studio from scratch.

Error Running App Default Activity not found

Screenshot of ErrorI am randomly getting an error when running my code. It was working a few hours earlier, but when I restarted my computer I can't run the code. I never changed my AndroidManifest, so I don't see why this error would occur. I tried rebuilding the project and invalidating the caches but it still doesn't work.
AndroidManifest.xml
<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"/>
<activity android:name=".StartUpActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".LogInActivity" />
<activity android:name=".SignUpActivity"></activity>
</application>
There is not error log all its says is "Default activity not found"
Also the red MainActivity says
"Unresolved class 'MainActivity' less... (Ctrl+F1)
Validates resource references inside Android XML files."
It's a long shot, but from the information that you've provided, I can say that I've had a degree of success doing the following:
File -> Invalidate Caches / Restart
It seems that you have a couple of errors there, and a little more information would make it easier to assist you (maybe show your full AndroidManifest.xml so that we can check other aspects of the file for errors).
1. Select Edit Configurations from the drop down next to run button.
2. Under launch options > Launch select Specified activity.
3. Another field "Activity" will appear select your default activity.
4. Click OK and sync project with gradle files and it should work.

Aapt dumb badging error

When I tried to upload signed application. Play store shows android manifest.xml.343 error getting 'android:label' value references does not exist. I checked AndroidManifest.xml and Strings line by line but unfortunately I didn't figure out.
For simulate same error locally. I run "./aapt dump badging myapp.apk" It shows same error.
Manifest file
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:name,android:theme">
<activity
android:name=".settings.ui.MainBoardActivity"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="#style/masterapp_core_theme.NoActionBar" />
<activity
android:name=".settings.ui.MASplashScreenActivity"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
.........
</application>
Add below line inside <application> tag
android:label="#string/app_name"
After two day later I figure out how to approach the problem. First I found appt tool which is under the sdk/build-tools directory. When I run appt dump badging myapp.apk I saw label attribute value was empty. But problem was I have already defined it. To be sure I typed hardcoded value without referenced #string/name like that. But It doesn't solve.
Finally I compared changes in last month so problem was I defined string value at string.xml(tr) on the other module of project but I didn't define it on default string.xml. So aapt couldnt find references on default :)

Manifest XML not well-formed (invalid token) Android

So, I think I accidentally deleted something from the manifest, but I am using AIDE and I no longer have the option to undo it. I've looked through examples on StackOverflow and throughout the general Internet, trying to find the problem with the manifest, but nothing seems to be missing. The error is showing after the android:label line in <activity>.
Before supposedly deleting something, the app compiled and ran as expected. Thanks to anyone that can help.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bitcoin.app" >
<uses-permission android:name = "android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It means there is a compilation error in your XML file, something that shouldn't be there: a spelling mistake/a spurious character/an incorrect namespace.
Check your #string file and XML file.
Eg: android:text="#string/hello";
a semicolon that shouldn't be there after this line

Categories

Resources