SecurityException: Not allowed to start service Intent act=com.google.android.c2dm.intent.REGISTER

匿名 (未验证) 提交于 2019-12-03 02:15:02

问题:

I get the error SecurityException: Not allowed to start service Intent but looks like it do not have good solution after searching many topics.

Please help me,

Thanks,

p/s :

I'm make sure I used correct SENDER_ID as project number was defined at Google API Console and correct package name.

Error :

Manifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"       package="app.cloudstringers" >  <application     android:allowBackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/AppTheme" >     <activity         android:name="app.cloudstringers.Cloudstringers"         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="ui.fragment.RegisterWithAccountsFragment" />      <meta-data android:name="com.google.android.gms.version"                android:value="@integer/google_play_services_version" />      <permission         android:name="app.cloudstringers.permission.C2D_MESSAGE"         android:protectionLevel="signature" />      <!-- Receiver GCM -->     <receiver         android:name="app.cloudstringers.GcmBroadcastReceiver"         android:permission="com.google.android.c2dm.permission.SEND" >         <intent-filter>             <action android:name="com.google.android.c2dm.intent.RECEIVE" />             <category android:name="app.cloudstringers" />         </intent-filter>     </receiver>      <!-- Service GCM -->     <service         android:exported="true"         android:name="app.cloudstringers.GcmIntentService" />      <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />     <uses-permission android:name="app.cloudstringers.permission.C2D_MESSAGE" />     <uses-permission android:name="android.permission.GET_ACCOUNTS" />     <uses-permission android:name="android.permission.INTERNET" />     <uses-permission android:name="android.permission.WAKE_LOCK" />  </application> 

SOLUTION I put wrong lines. Should put <use-permission> tag outside of <application> tag.

回答1:

Change to this:

    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />     <uses-permission android:name="app.cloudstringers.permission.C2D_MESSAGE" />     <uses-permission android:name="android.permission.GET_ACCOUNTS" />     <uses-permission android:name="android.permission.INTERNET" />     <uses-permission android:name="android.permission.WAKE_LOCK" />       <permission         android:name="app.cloudstringers.permission.C2D_MESSAGE"         android:protectionLevel="signature" />     <application     android:allowBackup="true"     android:icon="@drawable/ic_launcher"     android:label="@string/app_name"     android:theme="@style/AppTheme" >     <activity         android:name="app.cloudstringers.Cloudstringers"         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="ui.fragment.RegisterWithAccountsFragment" />      <meta-data android:name="com.google.android.gms.version"                android:value="@integer/google_play_services_version" />        <!-- Receiver GCM -->     <receiver         android:name="app.cloudstringers.GcmBroadcastReceiver"         android:permission="com.google.android.c2dm.permission.SEND" >         <intent-filter>             <action android:name="com.google.android.c2dm.intent.RECEIVE" />             <category android:name="app.cloudstringers" />         </intent-filter>     </receiver>      <!-- Service GCM -->     <service         android:exported="true"         android:name="app.cloudstringers.GcmIntentService" />    </application> 

You should put <use-permission> tag outside of <application> tag.



回答2:

You should check if play store can work or not. If it does not work, it can not start google service.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!