Question

I am in the beginning stages of adding Google C2D capabilities to my application. I read over the documentation carefully but I still get an IllegalStateException. First here is the stack when I try to run my application:

03-24 21:29:36.425: E/AndroidRuntime(3380): FATAL EXCEPTION: main
03-24 21:29:36.425: E/AndroidRuntime(3380): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maxap.lj3/com.maxap.lj3.MainActivity}:   java.lang.IllegalStateException: Application does not define permission com.maxap.lj3.permission.C2D_MESSAGE
03-24 21:29:36.425: E/AndroidRuntime(3380):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180) .......

I do define that permission in my manifest. Here is a copy of my manifest:

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

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" />
   <uses-permission  android:name="android.permissions.INTERNET" />

 <uses-permission android:name="com.maxap.lj3.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature"/>
        <uses-permission android:name="com.maxap.lj3.gcm.permission.C2D_MESSAGE" /> 
        <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

I appreciate any help. Thank you.

Was it helpful?

Solution

Try changing:

<uses-permission android:name="com.maxap.lj3.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature"/>

To

<permission android:name="com.maxap.lj3.gcm.permission.C2D_MESSAGE" android:protectionLevel="signature"/>

You were trying to use the com.maxap.lj3.gcm.permission.C2D_MESSAGE permission, but in your manifest you didn't declare it properly. You need to use <permission> not <uses-permission> to declare them.

OTHER TIPS

Try changing your manifest slightly to the following:

<!-- Settings for GCM -->
<permission
    android:name="com.maxap.lj3.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.maxap.lj3.permission.C2D_MESSAGE" />

<!-- App receives GCM messages. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- 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" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top