2016-10-15 85 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,它的功能如同一個魅力:) –

相關問題