2013-10-07 228 views
0

我正在GCM獲取。我的應用程序甚至沒有啓動和獲取crahsed。以下錯誤GCM錯誤(權限錯誤)

<uses-sdk 
    android:minSdkVersion="8" 
    android:targetSdkVersion="15" /> 
<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
<uses-permission android:name="android.permission.CALL_PHONE" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 
<uses-permission android:name="android.permission.VIBRATE" /> 
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
<!-- FOR GCM START1 --> 
<permission 
    android:name="com.ama.gcmdemo.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 
<uses-permission android:name="com.ama.gcmdemo.permission.C2D_MESSAGE" /> 
<!-- App receives GCM messages. --> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
<!-- GCM connects to Google Services. --> 
<!-- GCM requires a Google account. --> 
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
<!-- Keeps the processor from sleeping when a message is received. --> 
<uses-permission android:name="android.permission.WAKE_LOCK" /> 
<!-- FOR GCM END1 --> 
<application 
    android:allowBackup="true" 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:screenOrientation="portrait" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name="com.ama.gcmdemo.MainActivityActivity" 
     android:label="@string/app_name" 
     android:screenOrientation="portrait" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
      <receiver 
     android:name="com.google.android.gcm.GCMBroadcastReceiver" 
     android:permission="com.google.android.c2dm.permission.SEND" > 
     <intent-filter> 
      <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
      <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 

      <category android:name="com.ama.gcmdemo" /> 
     </intent-filter> 
    </receiver> 
    <service android:name=".GCMIntentService" /> 
    <service android:name=".DialogService" /> 
</application> 

並獲得以下錯誤

 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ama.gcmdemo/com.ama.gcmdemo.MainActivityActivity}: java.lang.IllegalStateException: Application does not define permission com.ama.gcmdemo.permission.C2D_MESSAGE 

主要業務是com.ama.gcmdemo包下直接。

請建議哪裏是錯

+0

有你加入您應用程序中的GCM庫? – GrIsHu

回答

0

給這個權限清單文件

<permission 
    android:name="<package-name>.permission.C2D_MESSAGE" 
    android:protectionLevel="signature" /> 

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

<!-- This app has permission to register and receive data message. --> 
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 

到位包名的給你包名

+0

com.ama.gcmdemo是已存在的軟件包名稱 – Gaurav

0

試試這個..

剛在接收器內改變下面的線,

android:name="com.google.android.gcm.GCMBroadcastReceiver" 

到,

android:name="com.ama.gcmdemo.GCMBroadcastReceiver" 

,並確保你有你的包內GCMBroadcastReceiver.java。 Bcs,您應該在包裝內部安裝接收器以接收GCM信息。

+0

無法繼續工作 – Gaurav

+0

請檢查我的編輯.. – Hariharan

0

您需要與GCM包的名字不是你的應用程序包,如下名稱定義recevier:

 <receiver 
    android:name="com.google.android.gcm.GCMBroadcastReceiver"> 

<receiver 
     android:name="com.google.android.gcm.GCMBroadcastReceiver"