2016-10-15 2 views
0

Android Studio와 함께 Windows PC에서 구문 분석을 사용하려고합니다.내 로컬 구문 분석 서버가 ​​작동하지 않습니다.

나는 MongoDB, Parse 서버 및 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> 

변경

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); 
    } 
} 
: 여기 내 구문 분석 서버

를 설정하고 같은 것과 같은 키와 클라이언트 ID는 시작 응용 프로그램 활동에 대한 코드입니다

코드를 실행 한 후에 Parse : failure!
난 당신이 앱에서 코드를 실행하면 내 코드

답변

2

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

뭐가 잘못된 건지 모르겠다, localhost는 "이 장치"AKA 안드로이드 장치가 아닌 서버를 의미한다.

에뮬레이터 또는 물리적 장치를 사용하는 경우에 따라 서버의 IP 주소를 사용해야합니다.

+0

완벽하게 잘 작동 한 사람에게 감사드립니다! 로컬 호스트를 10.0.2.2로 변경했으며 매력적으로 작동합니다.) –

관련 문제