android GCM寄存器包中的未知权限

时间:2014-02-21 13:16:36

标签: android google-cloud-messaging android-c2dm

我正在尝试获取Android设备的注册ID,但我收到以下警告:

    02-21 18:23:46.437: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.437: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.437: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.437: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.437: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.437: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.445: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.445: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.445: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.445: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.445: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.445: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.445: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.445: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.453: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.453: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.453: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.453: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.453: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.453: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.460: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.468: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.476: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.476: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.476: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.476: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.476: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.484: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.484: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.484: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.484: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.484: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.484: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.484: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.484: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.484: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.484: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.492: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.492: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.492: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.492: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.492: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.492: W/PackageManager(1495): Not granting permission to package (protectionLevel flags)
02-21 18:23:46.500: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.500: W/PackageManager(1495): Unknown permission in package 
02-21 18:23:46.500: W/PackageManager(1495): Unknown permission in package 

我的应用程序清单文件如下:

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

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

<uses-permission android:name="com.google.android.c2dm.intent.REGISTRATION" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<permission
    android:name="package1.package2.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main" 
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="SampleActivity"
        android:label="@string/title_activity_main"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="SearchResult"
        android:label="@string/title_activity_main"
        android:screenOrientation="portrait" >
    </activity>
    <activity
        android:name="ShowProduct"
        android:label="@string/title_activity_main" 
        android:screenOrientation="portrait">
    </activity>     

    <receiver
        android:name="package1.package2.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="package1.package2" />
        </intent-filter>

    </receiver>
    <service android:name="package1.package2.GCMServiceHandler"></service>
</application>

</manifest>

尝试注册设备时,我也收到错误SERVICE_NOT_AVAILABLE。

2 个答案:

答案 0 :(得分:0)

对我来说显而易见的是“。”在这样的面前

<service android:name=".GCMServiceHandler"></service>

或使用完整路径

<service android:name="com.example.webserviceaccess.GCMServiceHandler"></service>

权限名称也必须正确。如果您更改包名称,清理项目并右键单击项目 - Android工具&gt;修复项目属性

我不在我的项目中使用它并且它正在工作,请尝试删除

 <uses-permission android:name="com.google.android.c2dm.SEND" />
 <uses-permission android:name="com.google.android.c2dm.intent.REGISTRATION" />

答案 1 :(得分:0)

通过将protectionLevel“normal”更改为“signature”作为

来尝试
  android:protectionLevel="signature"