2016-10-15 82 views
0

我正尝试在Android Studio上使用我的Windows PC上的分析。我的本地分析服务器无法正常工作

我遵循一些教程来安装MongoDB,Parse服务器和Parse仪表板,并且一切顺利。

当我打开Android Studio中,解析服务器初始化,但它不保存数据,我也不是什么地方出了错

这里是我的清单代码:

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

我改变密钥和客户端ID,当我把我的解析服务器

这里同那些对于启动应用程序的活动代码:

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:失败!
我不知道,当你在你的应用程序运行的代码有什么错我的代码

回答

2

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

localhost意思是“此设备” AKA你的Android设备,而不是服务器。

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

+0

感谢那个工作完美的人!我将本地主机更改为10.0.2.2,它的功能如同一个魅力:) –

相关问题