无法解析'R.string.gcm_send_message'

时间:2015-09-26 20:15:45

标签: android google-cloud-messaging

我知道为什么会收到此错误?在尝试使用cannot resolve R.string.token_error_message

时,与cannot resolve R.string.registrationProgressBarGCM一起使用

我认为问题发生在Manifest,所以我做了各种改动,但没有任何帮助。

清单:

<manifest
    package="com.example.android.bluetoothchat"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:versionCode="1"
    android:versionName="1.0">

    <!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->

    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <!-- GCM START -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

    <permission android:name="com.example.android.bluetoothchat.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission android:name="com.example.android.bluetoothchat.permission.C2D_MESSAGE" />

    <!-- GCM END -->

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">

        <!-- GCM START -->
        <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.example.android.bluetoothchat" />
            </intent-filter>
        </receiver>

        <service
            android:name=".MyGcmListenerService"
            android:exported="false" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>
        <service
            android:name=".MyInstanceIDListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID"/>
            </intent-filter>
        </service>

        <!-- GCM END -->
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden"
            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=".DeviceListActivity"
            android:configChanges="orientation|keyboardHidden"
            android:label="@string/select_device"
            android:theme="@android:style/Theme.Holo.Dialog"/>

    </application>

</manifest>

1 个答案:

答案 0 :(得分:2)

看看这个link。看来,您应该在您的项目QList<QGraphicsItem*> graphicsItemList = m_pGraphicsScene->items(); foreach(QGraphicsItem* pGraphicsItems, graphicsItemList) { QGraphicsProxyWidget* pProxy = qgraphicsitem_cast<QGraphicsProxyWidget*>(pGraphicsItems); if(pProxy) { QLineEdit* pLineEdit = qobject_cast<QLineEdit*>(pProxy->widget()); if(pLineEdit) // do stuff } } 中创建自己的字符串,并为您的布局添加strings.xml

要添加的字符串(来自链接abowe):

ProgressBar

此外,您的布局必须包含ID为<string name="gcm_send_message">Token retrieved and sent to server! You can now use gcmsender to send downstream messages to this app.</string> <string name="registering_message">Generating InstanceID token...</string> <string name="token_error_message">An error occurred while either fetching the InstanceID token, sending the fetched token to the server or subscribing to the PubSub topic. Please try running the sample again.</string> 的{​​{1}}:

ProgressBar