gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 23:10:58 26 4
gpt4 key购买 nike

我收到错误 SecurityException: Not allowed to start service Intent但是搜索了很多主题后似乎没有很好的解决方案。

请帮帮我,

谢谢,

p/s:

我确定我使用了正确的 SENDER_ID因为项目编号定义在 Google API Console并更正package name .

错误:

Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
at android.app.ContextImpl.startServiceAsUser(ContextImpl.java:1785)
at android.app.ContextImpl.startService(ContextImpl.java:1757)
at android.content.ContextWrapper.startService(ContextWrapper.java:480)
at com.google.android.gms.gcm.GoogleCloudMessaging.e(Unknown Source)
at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
at controller.RegisterGCMClientAsync.doInBackground(RegisterGCMClientAsync.java:62)
at controller.RegisterGCMClientAsync.doInBackground(RegisterGCMClientAsync.java:18)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:841)

Manifest.xml 文件:

<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>

解决方案我放错了台词。应该放<use-permission> <application> 之外的标签标记。

最佳答案

改成这样:

    <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>

你应该把 <use-permission> <application> 之外的标签标记。

关于android - SecurityException : Not allowed to start service Intent act=com. google.android.c2dm.intent.REGISTER,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25399845/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com