我的本地解析服务器不工作

my local Parse server is not working

我正尝试在我的 Windows PC 上与 Android Studio 一起使用 Parse。

我按照一些教程安装了 MongoDB、Parse 服务器和 Parse 仪表板,一切都很顺利。

当我打开 Android Studio 时,Parse 服务器会初始化,但它不会保存数据,我也不知道哪里出了问题

这是我的清单代码:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.parse.starter" >

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:name=".StarterApplication"
        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="kooora.com100plus" />
        <meta-data
            android:name="com.parse.CLIENT_KEY"
            android:value="kooora.com100plusMasterKey" />

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

我在设置 Parse Server 时将密钥和客户端 ID 更改为相同的

这里是启动应用程序的代码Activity:

public class StarterApplication extends Application {

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

    // Enable Local Datastore.
        Parse.enableLocalDatastore(this);

    // Add your initialization code here

        Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
            .applicationId("kooora.com100plus")
            .clientKey("kooora.com100plusMasterKey")
            .server("http://localhost:1337/parse/")
            .build()
        );


        ParseObject gameScore = new ParseObject("GameScore");
        gameScore.put("score", 1337);
        gameScore.put("playerName", "Sean Plott");
        gameScore.put("cheatMode", false);
        gameScore.saveInBackground(new SaveCallback() {
        public void done(ParseException e) {
        if (e == null) {
          Log.i("Parse", "Save Succeeded");
        } else {
          Log.i("Parse", e.getMessage());
        }
          }
        });

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

在我 运行 代码之后,我得到了 Parse: failure!
我不知道我的代码有什么问题

.server("http://localhost:1337/parse/")

当您 运行 应用中的代码时,localhost 表示 "this device" 也就是您的 Android 设备,而不是服务器。

您需要使用那里服务器的 IP 地址(这取决于您使用的是模拟器还是物理设备)。