2012-06-12 174 views
3
com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime java.lang.RuntimeException: Unable to start service [email protected] with Intent { act=com.urbanairship.push.START cmp=com.myapp.myapp/com.urbanairship.push.PushService }: java.lang.IllegalStateException: UAirship.takeOff() must be called every time Application.onCreate() is invoked. 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2499) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at android.app.ActivityThread.access$1900(ActivityThread.java:132) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1220) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at android.os.Handler.dispatchMessage(Handler.java:99) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at android.os.Looper.loop(Looper.java:137) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at android.app.ActivityThread.main(ActivityThread.java:4575) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at java.lang.reflect.Method.invokeNative(Native Method) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at java.lang.reflect.Method.invoke(Method.java:511) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at dalvik.system.NativeStart.main(Native Method) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime Caused by: java.lang.IllegalStateException: UAirship.takeOff() must be called every time Application.onCreate() is invoked. 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at com.urbanairship.push.PushService.onStart(Unknown Source) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at android.app.Service.onStartCommand(Service.java:438) 
23:03:56.422 21926 com.myapp.myapp:com.urbanairship.process ERROR AndroidRuntime  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2482) 

我想UrbanAirship融入我的應用程序,我稱之爲起飛後上述異常被拋出,如果我修改該行:UrbanAirship Android的廣播接收器

<service android:name="com.urbanairship.push.PushService" android:process=":com.urbanairship.process"/> 

..變得沒有了Android :進程的一部分它的工作原理,但是當推郵件到達我的PushBroadcastReceiver不叫(該斷點未命中)

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
      android:versionName="3.61 beta 1" 
      android:versionCode="71" 
      android:installLocation="auto" package="com.myapp.myapp"> 

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


    <uses-feature android:name="android.hardware.camera"/> 
    <application 
     android:label="@string/app_name"> 
     <activity android:name=".client.android.SplashScreen" 
       android:screenOrientation="portrait" 
       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=".client.android.CaptureActivity" 
       android:screenOrientation="landscape" 
       android:configChanges="orientation|keyboardHidden" 
       android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
       android:windowSoftInputMode="stateAlwaysHidden"> 
      <intent-filter> 
       <action android:name="com.myapp.myapp.client.android.CaptureActivity" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 
     <activity android:name=".client.android.PreferencesActivity" 
       android:label="@string/preferences_name" 
       android:screenOrientation="portrait"> 

     </activity> 

     <activity android:name=".client.android.PushBroadcastReceiver"> 

     </activity> 

     <activity android:name=".client.android.AboutActivity" 
       android:label="@string/menu_about"> 
      <intent-filter> 
       <action android:name="com.myapp.myapp.client.android.AboutActivity" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 

     </activity> 

     <receiver android:name="com.urbanairship.CoreReceiver"> 
      <intent-filter> 
       <action android:name="android.intent.action.BOOT_COMPLETED" /> 
       <action android:name="android.intent.action.ACTION_SHUTDOWN" /> 
      </intent-filter> 
     </receiver> 

     <receiver android:name="com.urbanairship.push.c2dm.C2DMPushReceiver" 
       android:permission="com.google.android.c2dm.permission.SEND"> 

      <intent-filter> 
       <action android:name="com.google.android.c2dm.intent.RECEIVE" /> 
       <category android:name="com.myapp.myapp" /> 
      </intent-filter> 

      <intent-filter> 
       <action android:name="com.google.android.c2dm.intent.REGISTRATION" /> 
       <category android:name="com.myapp.myapp" /> 
      </intent-filter> 

     </receiver> 

     <service android:name="com.urbanairship.push.PushService" android:process=":com.urbanairship.process"/> 
     <receiver android:name="com.myapp.myapp.client.android.PushBroadcastReceiver" /> 

    </application> 


    <uses-permission android:name="android.permission.CAMERA"/> 
    <uses-permission android:name="android.permission.READ_CONTACTS"/> 
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/> 
    <uses-permission android:name="android.permission.VIBRATE"/> 
    <uses-permission android:name="android.permission.FLASHLIGHT"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

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


    <uses-permission android:name="android.permission.WRITE_SETTINGS" /> 
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> 
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.WAKE_LOCK" /> 

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

    <!-- This app has permission to register and receive message --> 
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 

</manifest> 

回答

0

當你打電話的騰飛?看起來您沒有使用AutoPilot或提供調用onCreate方法中的起飛的自定義應用程序。

首先創建一個調用騰飛CustomApplication類:

public class CustomApplication extends Application { 

    @Override 
    public void onCreate() { 
     super.onCreate(); 

     // Optionally, customize your config at runtime: 
     // 
     // AirshipConfigOptions options = new AirshipConfigOptions(); 
     // options.inProduction = false; 
     // options.developmentAppKey = "Your Development App Key"; 
     // options.developmentAppSecret "Your Development App Secret"; 
     // 
     // UAirship.takeOff(this, options); 

     UAirship.takeOff(this, new UAirship.OnReadyCallback() { 
      @Override 
      public void onAirshipReady(UAirship airship) { 
       // Perform any airship configurations here 
      } 
     }); 
    } 
} 

然後在清單中設置的應用程序: <application name="CustomApplication"

我也想從你的清單中刪除的使用流程。他們幾乎不再是一個好主意。它們會使應用程序邏輯複雜化並浪費更多資源。

有關城市飛艇更多信息 - http://docs.urbanairship.com/platform/android.html