4

i am trying to use the parse.com push service with Qt5.5 on Android. When trying to call ParseInstallation.getCurrentInstallation() i get the following error:

W/System.err( 9094): java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.File com.parse.ParsePlugins.getParseDir()' on a null object reference
W/System.err( 9094):    at com.parse.ParseCorePlugins.getCurrentInstallationController(ParseCorePlugins.java:272)
W/System.err( 9094):    at com.parse.ParseInstallation.getCurrentInstallationController(ParseInstallation.java:52)
W/System.err( 9094):    at com.parse.ParseInstallation.getCurrentInstallation(ParseInstallation.java:57)

Here is my code:

QAndroidJniEnvironment env;

if (!QAndroidJniObject::isClassAvailable("com/parse/Parse")) {
    qDebug() << "com/parse/Parse not available";
    return;
}

if (!QAndroidJniObject::isClassAvailable("com/parse/ParseInstallation")) {
    qDebug() << "com/parse/ParseInstallation not available";
    return;
}

QAndroidJniObject applicationId = QAndroidJniObject::fromString("MY_PARSE_APPLICATION_ID");
QAndroidJniObject clientKey = QAndroidJniObject::fromString("MY_PARSE_CLIENT_ID");
QAndroidJniObject activity = QtAndroid::androidActivity();

if (!activity.isValid()) {
    qDebug() << "invalid activity";
}

QAndroidJniObject application = activity.callObjectMethod("getApplication", "()Landroid/app/Application;");
if (!application.isValid()) {
    qDebug() << "invalid application";
}

qDebug() << env->ExceptionCheck();

QAndroidJniObject::callStaticMethod<void>("com/parse/Parse",
                      "enableLocalDatastore",
                      "(Ljava/lang/object;)V",
                      application.object<jobject>()
                      );
qDebug() << env->ExceptionCheck();

QAndroidJniObject::callStaticMethod<void>("com/parse/Parse",
                      "initialize",
                      "(Ljava/lang/object;Ljava/lang/String;Ljava/lang/String;)V",
                      application.object<jobject>(),
                      applicationId.object<jstring>(),
                      clientKey.object<jstring>()
                      );

qDebug() << env->ExceptionCheck();

// this is where it fails, until here all exception checks show no error:
QAndroidJniObject parseInstallation = QAndroidJniObject::callStaticObjectMethod("com/parse/ParseInstallation",
                                       "getCurrentInstallation",
                                       "()Lcom/parse/ParseInstallation;");

// here ExceptionCheck reports an error for the first time
qDebug() << env->ExceptionCheck();
// this gives the above error message
env->ExceptionDescribe();

if (!parseInstallation.isValid()) {
    qDebug() << "invalid parseInstallation";
    return;
}

My AndroidManifest.xml has the following, right before the opening application tag (myapp is an placeholder, the real app id is set up correct):

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>

<!--
  IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
  to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission android:protectionLevel="signature" android:name="myapp.permission.C2D_MESSAGE"/>
<uses-permission android:name="myapp.permission.C2D_MESSAGE"/>

...and the following right before the closing application tag:

<service android:name="com.parse.PushService"/>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" android:exported="false">
  <intent-filter>
    <action android:name="com.parse.push.intent.RECEIVE"/>
    <action android:name="com.parse.push.intent.DELETE"/>
    <action android:name="com.parse.push.intent.OPEN"/>
    </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"/>

    <!--
      IMPORTANT: Change "com.parse.starter" to match your app's package name.
    -->
    <category android:name="myapp"/>
  </intent-filter>
</receiver>

I actually used the v-play plugin until now, but it stopped working so i try to implement it myself, which means, the parse side is configured correct, because it used to work with the v-play plugin (until it stopped working ;) - but that is an error on the v-play side)

What am i doing wrong?

Hellagot
  • 235
  • 2
  • 13

0 Answers0