username
username

Reputation: 613

Android Studio 3.1.4 Cannot resolve symbol R

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.

Upvotes: 2

Views: 3776

Answers (1)

Firoz Memon
Firoz Memon

Reputation: 4680

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!

Upvotes: 4

Related Questions