parse.com推送通知在cordova上崩溃onCreate()

时间:2015-08-18 04:42:19

标签: java android cordova parse-platform

我用cordova构建了一个应用程序。当我尝试使用Unfortunately, MyApp has stoped消息实现Parse推送通知应用程序时。我将Parse-1.10.0.jar导入libs目录。

logcat的:

08-18 04:09:23.945: I/Timeline(2667): Timeline: Activity_launch_request id:com.myapp time:26719091
08-18 04:09:23.945: I/ActivityManager(976): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.myapp/.CordovaApp bnds=[63,96][255,288]} from uid 10019 on display 0
08-18 04:09:23.995: I/ActivityManager(976): Start proc com.myapp for activity com.myapp/.CordovaApp: pid=22881 uid=10163 gids={50163, 9997, 3003, 1028, 1015} abi=arm64-v8a
08-18 04:09:24.105: E/AndroidRuntime(22881): Process: com.myapp, PID: 22881
08-18 04:09:24.105: E/AndroidRuntime(22881): java.lang.NoSuchMethodError: No virtual method setFollowRedirects(Z)V in class Lcom/squareup/okhttp/OkHttpClient; or its super classes (declaration of 'com.squareup.okhttp.OkHttpClient' appears in /data/app/com.myapp-1/base.apk)
08-18 04:09:24.105: E/AndroidRuntime(22881):    at com.myapp.CordovaApp.onCreate(CordovaApp.java:35)
08-18 04:09:24.105: W/KloServer(2528): Aborted broadcast does not supprt for: com.myapp
08-18 04:09:24.105: W/ActivityManager(976):   Force finishing activity com.myapp/.CordovaApp
08-18 04:09:24.605: W/ActivityManager(976): Activity pause timeout for ActivityRecord{2ea81bdb u0 com.myapp/.CordovaApp t4028 f}
08-18 04:09:25.995: I/ActivityManager(976): Process com.myapp (pid 22881) has died

的AndroidManifest.xml

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="500" android:versionName="0.5" package="com.myapp" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <application android:debuggable="false" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="CordovaApp" android:screenOrientation="portrait" android:theme="@android:style/Theme.Black.NoTitleBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:exported="true" android:name="com.plugin.gcm.PushHandlerActivity" />
        <service android:name="com.parse.PushService" />
        <receiver android:name="com.parse.ParseBroadcastReceiver">
          <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
            <action android:name="android.intent.action.USER_PRESENT" />
          </intent-filter>
        </receiver>
        <receiver android:name="com.parse.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="com.myapp" />
          </intent-filter>
        </receiver>     
        <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/fb_app_id" />
        <activity android:label="@string/fb_app_name" android:name="com.facebook.LoginActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    </application>
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <permission android:name="com.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.myapp.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
</manifest>

CordovaApp.java

public class CordovaApp extends CordovaActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {

        Parse.initialize(this, "abc", "def"); //Line 35
        ParseInstallation.getCurrentInstallation().saveInBackground();
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xml
        loadUrl(launchUrl);

    }

1 个答案:

答案 0 :(得分:0)

我第一次将Parse-1.10.0.jar添加到parse-push-plugin时遇到了同样的问题。

您需要做的只是cordova platform update android,因为Parse期待更新版本的OkHttpClient