无法解析字符串符号AndroidManifest.xml

时间:2018-10-02 14:29:15

标签: java android

我正在使用此教程创建天气应用: https://blog.teamtreehouse.com/beginners-guide-location-android 我注意到由于某种原因,我得到了以下错误:'无法解析符号'R'和'无法解析符号'setUpMapIfNeeded()'。这些都是我已经尝试过的东西: 清理/构建项目,“文件”>“使缓存无效/重新启动..”,删除构建文件夹,首先同步Gradle,在settings.gradle中添加“ include':app'”,甚至导入.R,导入也遇到相同的错误。 。 最终,我发现我的.xml文件之一可能有问题。

事实证明,在我的AndroidManifest.xml文件的元数据部分下,android:value="@string/google_maps_key"/>被涂成红色,并且还显示“无法解析符号”。

这是完整的清单代码:

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

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<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">

    <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key"/>

    <activity
            android:name=".MapsActivity"
            android:label="@string/title_activity_maps">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>

            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>

google_maps_key只是用于访问天气数据的API密钥。实际的密钥在google_maps_api.xml中,这是其中的所有代码:

<resources>
<string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">YOUR_KEY_HERE</string>
</resources>

我仍然不明白为什么无法像其他2个符号一样解析google maps键字符串。我不知道该怎么办,我已经尝试了所有方法。以下也是主类的屏幕截图: enter image description here

2 个答案:

答案 0 :(得分:1)

来自String资源的错误。您粘贴错误,名称必须为php artisan queue:work --stop-when-empty

name="google_maps_key"

答案 1 :(得分:0)

选中https://github.com/treehouse/android-location-example

MapsActivity 中,实现了 setUpMapIfNeeded 方法