com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime  java.lang.RuntimeException: Unable to start service com.urbanairship.push.PushService@40cfdc08 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集成到我的应用程序中,如果我修改行,则在我调用takeoff之后会引发上述异常:
<service android:name="com.urbanairship.push.PushService" android:process=":com.urbanairship.process"/>

…如果没有android:process部分,它可以工作,但是当推送消息到达时,我的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>

最佳答案

你要从哪里起飞?看起来您没有在oncreate方法中使用autopilot或提供调用takeoff的自定义应用程序。
首先创建一个调用takeoff的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

10-07 16:41