2012-09-08 60 views
0

运行项目时出现错误,稍后我发送了有关此问题的信息,但是我使用Image支持。这个错误我在互联网上搜索了更多,但我找不到解决此问题的任何解决方案。我希望有人帮助我。使用GCM时应用程序意外停止

我测试了所有的代码,我发现该错误是在这里:

public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_elaraby_group); 

     GCMRegistrar.checkDevice(this); 
     GCMRegistrar.checkManifest(this); 
     final String regId = GCMRegistrar.getRegistrationId(this); 

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

清单

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

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

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

    <!-- 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:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".ElarabyGroup" 
      android:label="@string/title_activity_elaraby_group" > 
      <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=".ElarabyGroup" /> 
    </intent-filter> 
</receiver> 
<service android:name=".GCMIntentService" /> 
    </application> 


</manifest> 

error Log Cat

回答

0

您正在尝试一个设备或模拟器上运行的应用程序,没有Google服务框架。如果您使用模拟器进行测试,请务必使用包含Google API的模拟器图像。

+0

我使用模拟器我也测试了Android手机上的项目作为三星,但这个错误出现了,你是什么意思与谷歌服务? – egydeveloper

+0

@ user1644081:Google服务框架出现在合法拥有Play商店和相关应用的设备上。 – CommonsWare

+0

我在Android文件上下载了Google API,但错误依然存在于应用程序 – egydeveloper