2015-09-26 23 views
1

任何想法爲什麼我得到這個錯誤?嘗試使用GCM時與cannot resolve R.string.token_error_messagecannot resolve R.string.registrationProgressBar一起?無法解析'R.string.gcm_send_message'

我在想這個問題是在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> 
+0

心目中的進口,你可能已經導入了本地項目R,該GCM –

+0

的r爲你使用eclipse這掩蓋? – mohax

+0

它實際上可能是原因。但是我找不到R的輸入。你知道什麼是GCM的正確R輸入? –

回答

2

看這個link。這似乎是,你應該創建自己的串在你的項目strings.xml也可以增加ProgressBar到你的佈局

字符串添加(從鏈接abowe):

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

也是你的佈局必須包含ProgressBar ID爲registrationProgressBar

<ProgressBar 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/registrationProgressBar" /> 
+0

令人驚訝的是,你是對的。非常感謝。 –

+0

@OndrejTokar,不客氣) – mohax