【问题标题】:Android Studio 3.1.4 Cannot resolve symbol RAndroid Studio 3.1.4 无法解析符号 R
【发布时间】:2018-08-29 06:03:53
【问题描述】:

我知道有很多类似的问题,但没有一个能解决我的问题。

首先有一个错误:Cannot resolve symbol 'R'。同样在构建选项卡中,有一个错误:Build: build failed。旁边写着Manifest merger failed with multiple errors, see logs

我的程序有两个活动。

我已经尝试了人们说要尝试的所有不同方法,但都没有奏效。

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>

在合并清单选项卡中:

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)

更新:

您的设置活动声明应如下所示:

<activity android:name=".Settings"
    android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
    android:screenOrientation="landscape" />

这确实修复了 AndroidManifest.xml 错误。但是Cannot resolve symbol 'R' 仍然存在并且在构建选项卡中仍然存在错误:Build: build failed除了现在,它现在说的是AAPT2 error: check logs for details

还有人说要贴错误日志,我想知道:当我点击Help &gt; Show Log in Explorer时,它是正确的日志吗?因为有 12 条日志都包含超过 1000 行

感谢您的帮助,如果需要任何其他文件,请告诉我。

【问题讨论】:

  • 请发布您的日志
  • 检查你的布局drawable文件夹
  • 你试过see logs吗?
  • 打开一个 Manifest 文件,在底部有标签 Merged Manifest 点击它,它会在右侧显示错误
  • 尝试构建并发送构建错误

标签: android xml android-studio android-gradle-plugin android-studio-3.1.4


【解决方案1】:

你的错误信息很清楚:

缺少一个关键属性 'action#name,category#name,data#scheme,data#host,data#mimeType,data#port,data#path,data#pathPattern,data#pathPrefix' AndroidManifest.xml 中的元素意图过滤器

您的设置活动有空白intent-filter,删除它可以解决问题。

如果添加了intent-filter,它必须包含action标签和 可以/不能包含categorydata标签,Reference Android intent-filter doc

您的设置活动声明应如下所示:

    <activity android:name=".Settings"
        android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
        android:screenOrientation="landscape" />

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 2016-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-14
    • 2016-08-23
    • 1970-01-01
    • 2013-06-11
    • 2017-08-29
    相关资源
    最近更新 更多