简体   繁体   English

使用GCM进行推送通知时清单错误

[英]Error in Manifest while using GCM for push Notification

I have started working on GCM Notification after a lot of goggling i checked out code through which i can get registration id from GCM Server so i used 我已经开始了很多goggling的后GCM通知工作我检查了代码,通过它我可以从GCM服务器获得注册ID,所以我用

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);

final String regId= GCMRegistrar.getRegistrationId(this);

if (regId.equals("")) {
  GCMRegistrar.register(this, "338056690461");
}
else{
  Log.v(TAG, "Already registered");
}

  But When i run My Application i get error on   `CheckMAnifest()`

this means i have error in my manifest but accordint to me my manifest is correct please have alook to my Exception as well as manifest 这意味着我有错误在我的清单,但accordint我,我的清单是否正确,请有alook我的异常以及清单

Exception it gives 它给的异常

java.lang.IllegalStateException: Application does not define permission PushNotification.Pop.permission.C2D_MESSAGE

and manifest i have used is 我用过的清单是

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

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="8" />

    <permission
        android:name="PushNotification.Pop.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

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

    <!-- App receives GCM messages. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <!-- GCM connects to Google Services. -->
    <uses-permission android:name="android.permission.INTERNET" />
    <!-- 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" />

    <application android:debuggable="true" android:label="@string/app_name" >
        <activity
            android:name=".MainActivity">
            <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="PushNotification.Pop" />
            </intent-filter>
        </receiver>

       <service android:name=".GCMIntentService" />
    </application>

</manifest>

Please suggest me where i am going wrong your help would be greatfull Thanks in advance :) 请向我建议我要去哪里了,您的帮助将非常有用。

try to copy and paste this 尝试复制并粘贴此

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="PushNotification.Pop"
      android:versionCode="1"
      android:versionName="1.0">

    <uses-sdk android:minSdkVersion="8" 
              android:targetSdkVersion="17"/>


    <!-- GCM connects to Internet Services. -->
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" />
    <uses-permission android:name="android.permission.CALL_PHONE"/>  
    <uses-permission android:name="android.permission.VIBRATE" /> 


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

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

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


     <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 


     <permission
        android:name="indieswebs.magento.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />  

    <application android:icon="@drawable/ic_launcher" 
                 android:label="@string/app_name"
                >

        <activity android:name="PushNotification.Pop.MainActivity"
                  android:label="@string/app_name_title"
                  android:clearTaskOnLaunch="true"
                  android:configChanges="keyboardHidden|orientation">
            <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>

                <!-- Receives the actual messages. -->
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <!-- Receives the registration id. -->
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="PushNotification.Pop" />
            </intent-filter>
        </receiver>

        <service android:name="PushNotification.Pop.GCMIntentService" />

    </application>
</manifest>

or I got answer for this issue. 或者我得到了这个问题的答案。 Just delete "gen"folder . 只需删除“ gen”文件夹。 It build automatically. 它会自动构建。 Application will work fine. 应用程序将正常运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM