如何在heruko上成功运行parse.com Android应用程序并部署解析仪表板

时间:2017-07-13 14:11:20

标签: android parse-platform

我想在heruko上使用parse.com解析服务器开发一个新的Android应用程序。我按照所有正确的步骤将解析服务器部署到heruko,当我测试应用程序时它崩溃了,我得到一个零点异常这里是我的代码

        package com.example.machimanapc.starterapplication;

import android.app.Application;

import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseUser;


public class StarterApplication extends Application {

    @Override
    public void onCreate() {
        // Enable Local Datastore.
        Parse.enableLocalDatastore(this);




        String app_id = getResources().getString(R.string.parse_app_id);
        String client_key = getResources().getString(R.string.parse_client_key);
        String server = getResources().getString(R.string.parse_server);
// Add your initialization code here
        Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
                .applicationId(app_id).clientKey(client_key).server(server).build());



        ParseUser.enableAutomaticUser();
        ParseACL defaultACL = new ParseACL();
        // Optionally enable public read access.
        // defaultACL.setPublicReadAccess(true);
        ParseACL.setDefaultACL(defaultACL, true);
    }
}
Main Activity
      package com.example.machimanapc.starterapplication;

import android.app.Application;

import com.parse.Parse;
import com.parse.ParseACL;
import com.parse.ParseUser;


public class StarterApplication extends Application {

    @Override
    public void onCreate() {
        // Enable Local Datastore.
        Parse.enableLocalDatastore(this);




        String app_id = getResources().getString(R.string.parse_app_id);
        String client_key = getResources().getString(R.string.parse_client_key);
        String server = getResources().getString(R.string.parse_server);
// Add your initialization code here
        Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
                .applicationId(app_id).clientKey(client_key).server(server).build());



        ParseUser.enableAutomaticUser();
        ParseACL defaultACL = new ParseACL();
        // Optionally enable public read access.
        // defaultACL.setPublicReadAccess(true);
        ParseACL.setDefaultACL(defaultACL, true);
    }
}

清单

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.machimanapc.starterapplication" >
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <meta-data
            android:name="com.parse.APPLICATION_ID"
            android:value="@string/parse_app_id" />
        <meta-data
            android:name="com.parse.CLIENT_KEY"
            android:value="@string/parse_client_key" />
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

堆栈跟踪

  07-11 19:16:45.263    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? Zygote::ForkAndSpecialize : 0
07-11 19:16:45.265    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? zygote get new systemTid : 5888
07-11 19:16:45.265    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? Late-enabling CheckJNI
07-11 19:16:45.266    5888-5891/com.example.machimanapc.starterapplication D/dalvikvm? threadid=2: interp stack at 0x50a8f000
07-11 19:16:45.266    5888-5891/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.266    5888-5891/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.267    5888-5893/com.example.machimanapc.starterapplication D/dalvikvm? threadid=3: interp stack at 0x50bb0000
07-11 19:16:45.267    5888-5893/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.267    5888-5893/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.267    5888-5888/com.example.machimanapc.starterapplication D/jdwp? prepping for JDWP over ADB
07-11 19:16:45.267    5888-5893/com.example.machimanapc.starterapplication D/dalvikvm? Elevating priority from 0 to -8
07-11 19:16:45.268    5888-5894/com.example.machimanapc.starterapplication D/dalvikvm? threadid=4: interp stack at 0x53f22000
07-11 19:16:45.268    5888-5894/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.268    5888-5894/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.268    5888-5894/com.example.machimanapc.starterapplication D/jdwp? JDWP: thread running
07-11 19:16:45.269    5888-5894/com.example.machimanapc.starterapplication D/jdwp? trying to receive file descriptor from ADB
07-11 19:16:45.269    5888-5895/com.example.machimanapc.starterapplication D/dalvikvm? threadid=5: interp stack at 0x54040000
07-11 19:16:45.269    5888-5895/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.269    5888-5895/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.269    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? zygote get thread init done
07-11 19:16:45.269    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? create interp thread : stack size=128KB
07-11 19:16:45.269    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? create new thread
07-11 19:16:45.270    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? new thread created
07-11 19:16:45.270    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? update thread list
07-11 19:16:45.271    5888-5896/com.example.machimanapc.starterapplication D/dalvikvm? threadid=6: interp stack at 0x54060000
07-11 19:16:45.271    5888-5896/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.271    5888-5896/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.271    5888-5896/com.example.machimanapc.starterapplication D/dalvikvm? threadid=6: created from interp
07-11 19:16:45.271    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? start new thread
07-11 19:16:45.271    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? create interp thread : stack size=128KB
07-11 19:16:45.272    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? create new thread
07-11 19:16:45.272    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? new thread created
07-11 19:16:45.272    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? update thread list
07-11 19:16:45.272    5888-5896/com.example.machimanapc.starterapplication D/dalvikvm? threadid=6: notify debugger
07-11 19:16:45.272    5888-5896/com.example.machimanapc.starterapplication D/dalvikvm? threadid=6 (ReferenceQueueDaemon): calling run()
07-11 19:16:45.273    5888-5897/com.example.machimanapc.starterapplication D/dalvikvm? threadid=7: interp stack at 0x5417e000
07-11 19:16:45.273    5888-5897/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.273    5888-5897/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.273    5888-5897/com.example.machimanapc.starterapplication D/dalvikvm? threadid=7: created from interp
07-11 19:16:45.273    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? start new thread
07-11 19:16:45.273    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? create interp thread : stack size=128KB
07-11 19:16:45.273    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? create new thread
07-11 19:16:45.273    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? new thread created
07-11 19:16:45.273    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? update thread list
07-11 19:16:45.273    5888-5897/com.example.machimanapc.starterapplication D/dalvikvm? threadid=7: notify debugger
07-11 19:16:45.273    5888-5897/com.example.machimanapc.starterapplication D/dalvikvm? threadid=7 (FinalizerDaemon): calling run()
07-11 19:16:45.273    5888-5898/com.example.machimanapc.starterapplication D/dalvikvm? threadid=8: interp stack at 0x5429c000
07-11 19:16:45.273    5888-5898/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.273    5888-5898/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.273    5888-5898/com.example.machimanapc.starterapplication D/dalvikvm? threadid=8: created from interp
07-11 19:16:45.273    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? start new thread
07-11 19:16:45.276    5888-5898/com.example.machimanapc.starterapplication D/dalvikvm? threadid=8: notify debugger
07-11 19:16:45.277    5888-5898/com.example.machimanapc.starterapplication D/dalvikvm? threadid=8 (FinalizerWatchdogDaemon): calling run()
07-11 19:16:45.279    5888-5894/com.example.machimanapc.starterapplication D/jdwp? received file descriptor 40 from ADB
07-11 19:16:45.322    5888-5900/com.example.machimanapc.starterapplication D/dalvikvm? threadid=9: interp stack at 0x546b6000
07-11 19:16:45.322    5888-5900/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.322    5888-5900/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.325    5888-5901/com.example.machimanapc.starterapplication D/dalvikvm? threadid=10: interp stack at 0x547d4000
07-11 19:16:45.325    5888-5901/com.example.machimanapc.starterapplication D/dalvikvm? init ref table
07-11 19:16:45.325    5888-5901/com.example.machimanapc.starterapplication D/dalvikvm? init mutex
07-11 19:16:45.351    5888-5888/com.example.machimanapc.starterapplication V/Provider/Settings? get setting for user 0 by user 0 so skipping cache
07-11 19:16:45.352    5888-5888/com.example.machimanapc.starterapplication V/Provider/Settings? invalidate [system]: current 19 != cached 0
07-11 19:16:45.356    5888-5888/com.example.machimanapc.starterapplication D/ActivityThread? hoder:android.app.IActivityManager$ContentProviderHolder@41b723b8,provider,holder.Provider:android.content.ContentProviderProxy@41b72b30
07-11 19:16:45.359    5888-5888/com.example.machimanapc.starterapplication V/Provider/Settings? from db cache, name = anr_debugging_mechanism , value = 1
07-11 19:16:45.363    5888-5888/com.example.machimanapc.starterapplication D/asset? AssetManager-->addDefaultAssets CIP path not exsit!
07-11 19:16:45.368    5888-5888/com.example.machimanapc.starterapplication D/Proxy? setHttpRequestCheckHandler
07-11 19:16:45.373    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? open_cached_dex_file : /data/app/com.example.machimanapc.starterapplication-1.apk /data/dalvik-cache/data@app@com.example.machimanapc.starterapplication-1.apk@classes.dex
07-11 19:16:45.378    5888-5888/com.example.machimanapc.starterapplication D/ActivityThread? BIND_APPLICATION handled : 0 / AppBindData{appInfo=ApplicationInfo{41b6f708 com.example.machimanapc.starterapplication}}
07-11 19:16:45.392    5888-5888/com.example.machimanapc.starterapplication V/ActivityThread? ActivityRecord{41b71068 token=android.os.BinderProxy@41b70680 {com.example.machimanapc.starterapplication/com.example.machimanapc.starterapplication.MainActivity}}: app=android.app.Application@41b76a80, appName=com.example.machimanapc.starterapplication, pkg=com.example.machimanapc.starterapplication, comp={com.example.machimanapc.starterapplication/com.example.machimanapc.starterapplication.MainActivity}, dir=/data/app/com.example.machimanapc.starterapplication-1.apk
07-11 19:16:45.447    5888-5888/com.example.machimanapc.starterapplication I/dalvikvm? Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.internal.widget.TintTypedArray.getChangingConfigurations
07-11 19:16:45.447    5888-5888/com.example.machimanapc.starterapplication W/dalvikvm? VFY: unable to resolve virtual method 444: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
07-11 19:16:45.447    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? VFY: replacing opcode 0x6e at 0x0002
07-11 19:16:45.449    5888-5888/com.example.machimanapc.starterapplication I/dalvikvm? Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.internal.widget.TintTypedArray.getType
07-11 19:16:45.449    5888-5888/com.example.machimanapc.starterapplication W/dalvikvm? VFY: unable to resolve virtual method 466: Landroid/content/res/TypedArray;.getType (I)I
07-11 19:16:45.449    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? VFY: replacing opcode 0x6e at 0x0002
07-11 19:16:45.525    5888-5888/com.example.machimanapc.starterapplication E/dalvikvm? Could not find class 'bolts.TaskCompletionSource', referenced from method com.parse.ParseObject.enqueueForAll
07-11 19:16:45.525    5888-5888/com.example.machimanapc.starterapplication W/dalvikvm? VFY: unable to resolve new-instance 1723 (Lbolts/TaskCompletionSource;) in Lcom/parse/ParseObject;
07-11 19:16:45.525    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? VFY: replacing opcode 0x22 at 0x0000
07-11 19:16:45.554    5888-5888/com.example.machimanapc.starterapplication D/dalvikvm? DexOpt: unable to opt direct call 0x3835 at 0x02 in Lcom/parse/ParseObject;.enqueueForAll
07-11 19:16:45.592    5888-5888/com.example.machimanapc.starterapplication D/AndroidRuntime? Shutting down VM
07-11 19:16:45.592    5888-5888/com.example.machimanapc.starterapplication W/dalvikvm? threadid=1: thread exiting with uncaught exception (group=0x41882ce0)
07-11 19:16:45.592    5888-5888/com.example.machimanapc.starterapplication W/dalvikvm? threadid=1: uncaught exception occurred
07-11 19:16:45.592    5888-5888/com.example.machimanapc.starterapplication W/System.err? java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.machimanapc.starterapplication/com.example.machimanapc.starterapplication.MainActivity}: java.lang.NullPointerException
07-11 19:16:45.593    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
07-11 19:16:45.593    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
07-11 19:16:45.593    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.app.ActivityThread.access$800(ActivityThread.java:151)
07-11 19:16:45.593    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
07-11 19:16:45.593    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.os.Handler.dispatchMessage(Handler.java:110)
07-11 19:16:45.593    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.os.Looper.loop(Looper.java:193)
07-11 19:16:45.593    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.app.ActivityThread.main(ActivityThread.java:5299)
07-11 19:16:45.594    5888-5888/com.example.machimanapc.starterapplication W/System.err? at java.lang.reflect.Method.invokeNative(Native Method)
07-11 19:16:45.594    5888-5888/com.example.machimanapc.starterapplication W/System.err? at java.lang.reflect.Method.invoke(Method.java:515)
07-11 19:16:45.594    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
07-11 19:16:45.594    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
07-11 19:16:45.594    5888-5888/com.example.machimanapc.starterapplication W/System.err? at dalvik.system.NativeStart.main(Native Method)
07-11 19:16:45.594    5888-5888/com.example.machimanapc.starterapplication W/System.err? Caused by: java.lang.NullPointerException
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.parse.Parse.getParseDir(Parse.java:516)
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.parse.ParseCorePlugins.getCurrentUserController(ParseCorePlugins.java:130)
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.parse.ParseUser.getCurrentUserController(ParseUser.java:55)
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.parse.ParseUser.getCurrentUserAsync(ParseUser.java:883)
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.parse.ParseObject.saveInBackground(ParseObject.java:1405)
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.parse.ParseObject.saveInBackground(ParseObject.java:1529)
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at com.example.machimanapc.starterapplication.MainActivity.onCreate(MainActivity.java:25)
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.app.Activity.performCreate(Activity.java:5264)
07-11 19:16:45.595    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
07-11 19:16:45.596    5888-5888/com.example.machimanapc.starterapplication W/System.err? at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
07-11 19:16:45.596    5888-5888/com.example.machimanapc.starterapplication W/System.err? ... 11 more
07-11 19:16:45.596    5888-5888/com.example.machimanapc.starterapplication W/dalvikvm? threadid=1: calling UncaughtExceptionHandler
07-11 19:16:45.597    5888-5888/com.example.machimanapc.starterapplication E/AndroidRuntime? FATAL EXCEPTION: main
    Process: com.example.machimanapc.starterapplication, PID: 5888
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.machimanapc.starterapplication/com.example.machimanapc.starterapplication.MainActivity}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
            at android.os.Handler.dispatchMessage(Handler.java:110)
            at android.os.Looper.loop(Looper.java:193)
            at android.app.ActivityThread.main(ActivityThread.java:5299)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:825)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.parse.Parse.getParseDir(Parse.java:516)
            at com.parse.ParseCorePlugins.getCurrentUserController(ParseCorePlugins.java:130)
            at com.parse.ParseUser.getCurrentUserController(ParseUser.java:55)
            at com.parse.ParseUser.getCurrentUserAsync(ParseUser.java:883)
            at com.parse.ParseObject.saveInBackground(ParseObject.java:1405)
            at com.parse.ParseObject.saveInBackground(ParseObject.java:1529)
            at com.example.machimanapc.starterapplication.MainActivity.onCreate(MainActivity.java:25)
            at android.app.Activity.performCreate(Activity.java:5264)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)

在执行完所有正确的步骤后,我也遇到了部署解析仪表板的问题。我提供了错误截图图片enter image description here

1 个答案:

答案 0 :(得分:0)

这是我的。

public class App extends Application{


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

        OneSignal.startInit(this)
                .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)
                .init();

        Parse.enableLocalDatastore(this);

        Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
                .applicationId("TYPE_IN_YOUR_APP_ID")
                .clientKey("TYPE_IN_YOUR_CLIENT_KEY")
                .server("https://MY_HEROKU_URL.com/parse/")

                .build()
        );


        //ParseUser.enableAutomaticUser();
        ParseACL defaultACL = new ParseACL();
        // Optionally enable public read access.
        // defaultACL.setPublicReadAccess(true);
        ParseACL.setDefaultACL(defaultACL, true);

    }

}

清单

<uses-permission android:name="android.permission.INTERNET" />
        <application
            android:name=".App"
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="APP_NAME"
            android:largeHeap="true"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <activity
                android:name=".MainActivity"
                android:launchMode="standard"
                android:screenOrientation="portrait">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    </application>