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

1 に答える 1

0

どこからテイクオフを呼んでいますか? AutoPilot を使用していないか、onCreate メソッドで離陸を呼び出すカスタム アプリケーションを提供していないようです。

まず、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 をご覧ください。

于 2015-02-03T00:08:20.467 に答える